from header_common import *
from header_dialogs import *
from header_operations import *
from header_parties import *
from header_item_modifiers import *
from header_skills import *
from header_triggers import *
from ID_troops import *
from ID_party_templates import *

from module_constants import *


####################################################################################################################
# During a dialog, the dialog lines are scanned from top to bottom.
# If the dialog-line is spoken by the player, all the matching lines are displayed for the player to pick from.
# If the dialog-line is spoken by another, the first (top-most) matching line is selected.
#
#  Each dialog line contains the following fields:
# 1) Dialogue partner: This should match the person player is talking to.
#    Usually this is a troop-id.
#    You can also use a party-template-id by appending '|party_tpl' to this field.
#    Use the constant 'anyone' if you'd like the line to match anybody.
#    Appending '|plyr' to this field means that the actual line is spoken by the player
#    Appending '|other(troop_id)' means that this line is spoken by a third person on the scene.
#       (You must make sure that this third person is present on the scene)
#
# 2) Starting dialog-state:
#    During a dialog there's always an active Dialog-state.
#    A dialog-line's starting dialog state must be the same as the active dialog state, for the line to be a possible candidate.
#    If the dialog is started by meeting a party on the map, initially, the active dialog state is "start"
#    If the dialog is started by speaking to an NPC in a town, initially, the active dialog state is "start"
#    If the dialog is started by helping a party defeat another party, initially, the active dialog state is "party_relieved"
#    If the dialog is started by liberating a prisoner, initially, the active dialog state is "prisoner_liberated"
#    If the dialog is started by defeating a party led by a hero, initially, the active dialog state is "enemy_defeated"
#    If the dialog is started by a trigger, initially, the active dialog state is "event_triggered"
# 3) Conditions block (list): This must be a valid operation block. See header_operations.py for reference.  
# 4) Dialog Text (string):
# 5) Ending dialog-state:
#    If a dialog line is picked, the active dialog-state will become the picked line's ending dialog-state.
# 6) Consequences block (list): This must be a valid operation block. See header_operations.py for reference.
####################################################################################################################

dialogs = [
  [trp_tutorial_trainer,"start", [(eq, "$tutorial_quest_award_taken", 1),], "I think you have trained enough. Perhaps you should go to Zendar for the next step of your adventure.", "close_window",[]],
  [trp_tutorial_trainer,"start", [(store_character_level, ":player_level", "trp_player"),(gt, ":player_level", 1)], "I think you have trained enough. Perhaps you should go to Zendar for the next step of your adventure.", "close_window",[]],
  [trp_tutorial_trainer,"start", [(eq, "$tutorial_quest_taken", 0),], "Greetings stranger. What's your name?", "tutorial1_1",[]],
  [trp_tutorial_trainer|plyr, "tutorial1_1", [], "Greetings sir, it's {playername}.", "tutorial1_2", []],
  [trp_tutorial_trainer, "tutorial1_2", [], "Well {playername}, this place you see is the training ground. Locals come here to practice their combat skills. Since you are here you may have a go as well.", "tutorial1_3", []],
  [trp_tutorial_trainer|plyr, "tutorial1_3", [], "I'd like that very much sir. Thank you.", "tutorial1_4", []],
  [trp_tutorial_trainer, "tutorial1_4", [], "You will learn the basics of weapons and riding a horse here.\
  First you'll begin with melee weapons. Then you'll enter an archery range to test your skills. And finally you'll see a horse waiting for you.\
  I advise you to train in all these 3 areas. But you can skip some of them, it's up to you.", "tutorial1_6", []],
  [trp_tutorial_trainer, "tutorial1_6", [], "Tell you what, if you destroy at least 10 dummies while training, I will give you my old knife as a reward. It's a little rusty but it's a good blade.", "tutorial1_7", []],
  [trp_tutorial_trainer|plyr, "tutorial1_7", [(eq, "$tutorial_repeat_asked", 0),], "Sounds nice, I'm ready for training.", "tutorial1_9", []],
  [trp_tutorial_trainer, "tutorial1_9", [], "Good. Return to me when you have earned your reward.", "close_window", [(eq, "$tutorial_quest_taken", 0),(start_quest, "qst_destroy_dummies"),(assign, "$tutorial_quest_taken", 1)]],

  [trp_tutorial_trainer,"start", [(eq, "$tutorial_quest_taken", 1),
                                  (eq, "$tutorial_quest_succeeded", 1),], "Well done {playername}. Now you earned this knife. There you go.", "tutorial2_1",[]],
  [trp_tutorial_trainer|plyr, "tutorial2_1", [], "Thank you master.", "close_window", [(complete_quest, "qst_destroy_dummies"),(assign, "$tutorial_quest_award_taken", 1),(add_xp_to_troop, 100, "trp_player"),(troop_add_item, "trp_player","itm_knife",imod_chipped),]],

  [trp_tutorial_trainer,"start", [(eq, "$tutorial_quest_taken", 1),
                                  (eq, "$tutorial_quest_succeeded", 1),], "Greetings {playername}. Feel free to train with the targets.", "tutorial2_1",[]],

  [trp_tutorial_trainer,"start", [(eq, "$tutorial_quest_taken", 1),
                                  (eq, "$tutorial_quest_succeeded", 0),], "I don't see 10 dummies on the floor from here. You haven't earned your reward yet.", "tutorial3_1",[]],
  [trp_tutorial_trainer|plyr, "tutorial3_1", [], "Allright allright, I was just tired and wanted to talk to you while resting.", "tutorial3_2", []],
  [trp_tutorial_trainer, "tutorial3_2", [], "Less talk, more work.", "close_window", []],

  

    
  [trp_constable_hareck,"start", [(eq,"$constable_announcement",0)],
 "Hear me, people of Zendar, for I bear a message from our town's lord and protector, Count Arrasies.\
 As you know, bands of river pirates have infested the vicinity of our town.\
 These lawless villains devastate our realm, pillaging, robbing and murdering the innocent.\
 The mischief and suffering caused by these scum has become intolerable.\
 Thus, our good Count has found it necessary to call to arms his honest and law-abiding subjects against these murderous villains.",
   "constable_hareck_introduce_1",[(assign,"$constable_announcement",1)]],
  [trp_constable_hareck,"constable_hareck_introduce_1", [],
 "People of Zendar, our Count invites you to serve him in this cause.\
 Those of you that volunteer now will be equipped with arms and armor at the Count's expense\
 and shall be granted the right to hunt down the river pirates, ending their miserable lives by death or imprisonment,\
 and keeping their ill-gotten gains to yourselves without tax or tribute.\
 Moreover, you will be paid a reward of 20 denars from the Count's treasury for every river pirate group you vanquish.", "close_window",[]],

  [trp_constable_hareck,"start", [], "What do you want?", "constable_hareck_talk",[]],

  [trp_constable_hareck|plyr,"constable_hareck_talk", [(eq,"$quest_accepted_zendar_river_pirates",0)],
 "I want to sign up to hunt down the river pirates.", "constable_hareck_signup_1",[]],
  [trp_constable_hareck,"constable_hareck_signup_1", [], "Have you worked as a manhunter before?", "constable_hareck_signup_2",[]],
  [trp_constable_hareck|plyr,"constable_hareck_signup_2", [], "Yes I have.", "constable_hareck_signup_3",[]],
  [trp_constable_hareck|plyr,"constable_hareck_signup_2", [], "Not really. But I learn quickly", "constable_hareck_signup_3",[]],
  [trp_constable_hareck,"constable_hareck_signup_3", [],
 "That's more than enough for me. Well then. I charge you to hunt down river pirates around Zendar,\
 and give you this shield from the Count's armory.\
 May God make you victorious.", "constable_hareck_signup_4",[(assign,"$quest_accepted_zendar_river_pirates",1),(start_quest,"qst_hunt_down_river_pirates"),(troop_add_item, "trp_player","itm_wooden_shield",imod_battered)]],
  [trp_constable_hareck|plyr,"constable_hareck_signup_4", [], "Is that all?", "constable_hareck_signup_5",[]],
  [trp_constable_hareck,"constable_hareck_signup_5", [], "What else do you want, a good luck kiss?\
 Now stop chattering and go kill some outlaws. You have to work hard to deserve that shield.", "close_window",[]],
  
  [trp_constable_hareck,"sell_prisoner_outlaws_finished", [], "Well done my {boy/girl}. .", "close_window",[]],

  
  [trp_constable_hareck|plyr,"constable_hareck_talk", [
      (store_num_parties_destroyed_by_player, ":num_river_pirates_destroyed", "pt_river_pirates"),
      (val_min,":num_river_pirates_destroyed",num_max_river_pirates),
      (lt,"$river_pirates_paid_for",":num_river_pirates_destroyed")],
   "I have hunted down some river pirates.", "pay_for_river_pirates",[]],
  [trp_constable_hareck,"pay_for_river_pirates", [],
   "Yes, my scouts informed me. That should make them think twice before wandering near Zendar! Anyway, the reward is 20 denars for every river pirate party. Here is your money, as promised.",
   "pay_for_river_pirates_2",[(store_num_parties_destroyed_by_player, ":num_river_pirates_destroyed", "pt_river_pirates"),
                              (val_min,":num_river_pirates_destroyed",num_max_river_pirates),
                              (store_sub,":river_pirate_bounty",":num_river_pirates_destroyed","$river_pirates_paid_for"),
                              (val_mul,":river_pirate_bounty",20),
                              (troop_add_gold,"trp_player",":river_pirate_bounty"),
                              (assign,"$river_pirates_paid_for",":num_river_pirates_destroyed")]],
  [trp_constable_hareck|plyr,"pay_for_river_pirates_2", [],
   "Thank you, sir.", "pay_for_river_pirates_3",[]],
  [trp_constable_hareck,"pay_for_river_pirates_3", [(neq,"$quest_complete_zendar_river_pirates",0),(eq,"$quest_complete_zendar_river_pirates_ack",0)],
 "You certainly deserved your pay. Thanks to hunters like you most of the river pirates have been dealt with.\
 The few remaining do not pose a threat any longer. So I thank you in the name of the town of Zendar. You did a mighty good job.","constable_hareck_reward_1",[[add_xp_as_reward,100],[complete_quest,"qst_hunt_down_river_pirates"],[assign,"$quest_complete_zendar_river_pirates_ack",1]]],
  [trp_constable_hareck|plyr,"constable_hareck_reward_1", [], "Thank you sir. But does that mean you won't be paying any more rewards?", "constable_hareck_reward_2",[]],
  [trp_constable_hareck,"constable_hareck_reward_2", [], "You got that right.\
 The truth is, the count's accountant has found out that rewards cost him more than the pirates do.\
 So, that means no more rewards for those filthy pirates.\
 Nothing is stopping you from taking your own reward from their packs and hideouts, though.", "close_window",[]],
  [trp_constable_hareck,"pay_for_river_pirates_3", [], "Ah, yes... Well... good luck.", "close_window",[]],
  
  [trp_constable_hareck|plyr,"constable_hareck_talk", [], "Nothing. Good-bye.", "close_window",[]],

  [trp_marnid,"start",[(eq,"$marnid_introduced",0)],"Hello, you are new to the town aren't you. Would you be so kind to have a cup of wine with a fellow traveller?\
 I am here to waste my last five denars and I'd rather have someone help me with that.", "marnid_introduce_1",[[assign,"$marnid_introduced",1]]],
  [trp_marnid|plyr,"marnid_introduce_1",[],"Your last five denars? It seems that luck has not been at your side lately.", "marnid_introduce_2",[]],
  [trp_marnid,"marnid_introduce_2",[],"Luck? You know it comes and it goes.\
 Three months ago, I left Geroia with a caravan of goods. I was hoping to sell it all in Harlaushia and make a hefty sum.\
 But, what do you know... we were ambushed by a party of Khergit raiders who rode away with most of the horses and goods.\
 And two weeks later, my own caravan guards ran away with the rest of what I had.","marnid_introduce_3",[]],
  [trp_marnid|plyr,"marnid_introduce_3",[],"My sympathies friend. I hope your luck turns back soon.", "marnid_introduce_4",[]],
  [trp_marnid,"marnid_introduce_4",[],"Thanks... Anyway, my name is Marnid Rhaleis.", "marnid_introduce_5",[]],
  [trp_marnid|plyr,"marnid_introduce_5",[],"{playername}. What are you planning to do now?", "marnid_introduce_6",[]],
  [trp_marnid,"marnid_introduce_6",[],"Eh. I have no money left, no friends or relatives to ask for help.\
 The only way left for me is to enlist as a soldier and seek my fortune in war.", "marnid_introduce_7",[]],
  [trp_marnid|plyr,"marnid_introduce_7",[],"Do you have training in combat?", "marnid_introduce_8",[]],
  [trp_marnid,"marnid_introduce_8",[],"Not really. I guess I will have to learn it all the hard way, through battle.\
 But what worries me really is that I have no armor.\
 If I enlist now, they will surely place me among the peasant levies, and you know what that means.\
 I will be butchered in the first encounter with the enemy.\
 If only I had some serviceable armor, even a suit of padded cloth. Sigh.", "marnid_intro_talk",[]],

  [trp_marnid,"start", [(eq,"$marnid_joined_party",1),
                        (neg|main_party_has_troop,"trp_marnid"),
                        (neq, "$g_encountered_party", "p_four_ways_inn"),], "Do you want me to rejoin you?", "member_wilderness_talk",[]],
  [trp_marnid,"start", [(neg|main_party_has_troop,"trp_marnid"),(eq, "$g_encountered_party", "p_four_ways_inn")], "Do you want me to rejoin you?", "member_inn_talk",[]],
  [trp_marnid,"member_separate_inn", [], "All right then. I'll meet you at the four ways inn. Good luck.", "close_window",
   [(store_conversation_troop,reg(0)),(remove_member_from_party,reg(0)),(add_troop_to_site, reg(0), "scn_four_ways_inn",marnid_inn_entry)]],

  [trp_marnid,"start", [], "Hello {playername}.", "marnid_intro_talk",[]],
  [trp_marnid,"marnid_pre_free", [], "Yes?", "marnid_intro_talk",[]],
  [trp_marnid|plyr,"marnid_intro_talk", [], "Tell me about yourself.", "marnid_view_char_requested",[]],
  [trp_marnid,"marnid_view_char_requested", [], "You know, I am a ruined merchant. I know a thing or two about trade, a bit about riding and a few other things.", "marnid_pre_free",[[change_screen_view_character]]],
   
  [trp_marnid|plyr,"marnid_intro_talk", [(eq,"$marnid_joined_party")], "Would you fight in my service if I gave you a padded cloth?", "marnid_leather_hauberk_1",[]],
  [trp_marnid,"marnid_leather_hauberk_1", [(eq,"$marnid_join_party_answered")], "Well... Of course, why not? For all I know, you could be as good a captain as anyone else.\
 Yes I would gladly follow you to battle if you gave me a padded cloth.", "marnid_leather_hauberk_2",[(assign,"$marnid_join_party_answered",1)]],
  [trp_marnid,"marnid_leather_hauberk_1", [], "Yes, I haven't changed my mind. I would.", "marnid_leather_hauberk_2",[]],
  [trp_marnid|plyr,"marnid_leather_hauberk_2", [(player_has_item,"itm_padded_cloth")], "Then, take this padded cloth I have. I want you to join me.", "marnid_leather_hauberk_3_cloth",[]],
  [trp_marnid|plyr,"marnid_leather_hauberk_2", [(player_has_item,"itm_padded_leather"),(neg|player_has_item,"itm_padded_cloth")], "Then, take this padded leather I have. I want you to join me.", "marnid_leather_hauberk_3_leather",[]],
  [trp_marnid|plyr,"marnid_leather_hauberk_2", [], "Hmm. Let me think about this then.", "close_window",[]],
  [trp_marnid,"marnid_leather_hauberk_3_cloth", [(neg|hero_can_join,0)], "I would like to, friend. But I am afraid you don't have room for me in your party. Once you make room, let me know. I'm eager to leave this place.", "close_window",[]],
  [trp_marnid,"marnid_leather_hauberk_3_cloth", [], "Well, look at this. I feel that my luck is starting to turn back after all. I am at your service, friend. Let us hit the road and discover what adventures await us.", "close_window",[
	(troop_remove_item,0,"itm_padded_cloth"),(troop_add_item,"trp_marnid","itm_padded_cloth"),
	(troop_join,"trp_marnid"),(remove_troop_from_site,"trp_marnid"),(assign,"$marnid_joined_party",1)]],

  [trp_marnid,"marnid_leather_hauberk_3_leather", [(neg|hero_can_join,0)], "I would like to, friend. But I am afraid you don't have room for me in your party. Once you make room, let me know. I'm eager to leave this place.", "close_window",[]],
  [trp_marnid,"marnid_leather_hauberk_3_leather", [], "Well, look at this. I feel that my luck is starting to turn back after all. I am at your service, friend. Let us hit the road and discover what adventures await us.", "close_window",[
	(troop_remove_item,0,"itm_padded_leather"),(troop_add_item,"trp_marnid","itm_padded_leather"),
	(troop_join,"trp_marnid"),(remove_troop_from_site,"trp_marnid"),(assign,"$marnid_joined_party",1)]],

  [trp_marnid|plyr,"marnid_intro_talk", [], "I must leave now. Good-bye", "close_window",[]],




  [trp_ramun_the_slave_trader, "start", [(eq,"$ramun_introduced")], "Good day to you, {young man/girl}.", "ramun_introduce_1",[[assign,"$ramun_introduced",1]]],
  [trp_ramun_the_slave_trader|plyr, "ramun_introduce_1", [], "Good day, sir. You look like you are here for business. Are you a merchant?", "ramun_introduce_2",[]],
  [trp_ramun_the_slave_trader, "ramun_introduce_2", [], "Merchant? Aye. I am certainly a merchant.\
 But my merchandise is a bit peculiar. It has to be fed twice a day, and tries to run away if I turn my back.", "ramun_introduce_3",[]],
  [trp_ramun_the_slave_trader|plyr, "ramun_introduce_3", [], "Livestock?", "ramun_introduce_4",[]],
  [trp_ramun_the_slave_trader, "ramun_introduce_4", [], "Close enough. You see, most of the ships that come here are run by oars.\
 And they need men to pull those oars. But not free man. No that would be damn expensive.", "ramun_introduce_5",[]],
  [trp_ramun_the_slave_trader|plyr, "ramun_introduce_5", [], "Galley slaves.", "ramun_introduce_6",[]],
  [trp_ramun_the_slave_trader, "ramun_introduce_6", [], "Galley slaves, right. That's what I deal in.\
 The ships lose a few men at every voyage, and they are always short of enough slaves.\
 So they come to me, and they pay well.", "ramun_introduce_7",[]],
  [trp_ramun_the_slave_trader|plyr, "ramun_introduce_7", [], "Where do the slaves come from?", "ramun_introduce_8",[]],
  [trp_ramun_the_slave_trader, "ramun_introduce_8", [], "They are mostly convicted criminals, and prisoners of war.\
 I buy them off the authorities mostly. But I also work with privateers and other 'individuals'.\
 You can't be too picky about your suppliers in my line of work, you know.\
 Why, I would be happy to buy them from you too.", "ramun_introduce_9",[]],
  [trp_ramun_the_slave_trader|plyr, "ramun_introduce_9", [], "Me? ", "ramun_introduce_10",[]],
  [trp_ramun_the_slave_trader, "ramun_introduce_10", [], "You are an adventurer, right?\
 Eventually you are going to cross swords with someone out there, and if God permits, you will be victorious.\
 So while you are at it, why not make some extra money off the whole thing?\
 Capture your enemies alive, bring them to me and I will pay you a twenty denars for every one of them,\
 be they outlaws, or prisoners of war. No questions asked.", "ramun_introduce_11",[]],
  [trp_ramun_the_slave_trader|plyr, "ramun_introduce_11", [], "Hmm I will think about this.", "ramun_introduce_12",[]],
  [trp_ramun_the_slave_trader, "ramun_introduce_12", [], "Do think about it. I am always happy to deal with new suppliers.", "close_window",[]],

  [trp_ramun_the_slave_trader,"start", [], "Hello {playername}.", "ramun_talk",[]],
  [trp_ramun_the_slave_trader,"ramun_pre_talk", [], "Anything else?", "ramun_talk",[]],

  [trp_ramun_the_slave_trader|plyr,"ramun_talk",
   [[store_num_regular_prisoners,reg(0)],[ge,reg(0),1]],
   "I have brought you a few prisoners, Ramun. Would you like to have a look?", "ramun_sell_prisoners",[]],
  [trp_ramun_the_slave_trader,"ramun_sell_prisoners", [],
  "Let me see what you have...", "ramun_sell_prisoners_2",
   [[change_screen_trade_prisoners]]],
  [trp_ramun_the_slave_trader, "ramun_sell_prisoners_2", [], "It's good to do business with you.", "close_window",[]],

  [trp_ramun_the_slave_trader|plyr,"ramun_talk", [[eq,"$ch_explained_prisoners"]], "How do I take somebody as prisoner?", "ramun_ask_about_capturing",[[assign,"$ch_explained_prisoners",1]]],
  [trp_ramun_the_slave_trader|plyr,"ramun_talk", [[neq,"$ch_explained_prisoners"]], "Can you tell me again about capturing prisoners?", "ramun_ask_about_capturing",[]],

  [trp_ramun_the_slave_trader,"ramun_ask_about_capturing", [(eq,"$ramun_tip_given",0)],
 "You don't have much experience there, have you? Let me fill you in on the basics.\
 The basic rule of taking someone prisoner is beating him down with a blunt weapon like a mace or a club.\
 You have a blunt weapon don't you?", "ramun_have_blunt_weapon",[(assign,"$ramun_tip_given",1)]],
  [trp_ramun_the_slave_trader|plyr,"ramun_have_blunt_weapon", [],
 "Yes", "ramun_have_blunt_weapon_yes",[]],
  [trp_ramun_the_slave_trader|plyr,"ramun_have_blunt_weapon", [],
 "No", "ramun_have_blunt_weapon_no",[]],
  [trp_ramun_the_slave_trader,"ramun_have_blunt_weapon_yes", [],
 "Good. Then all you need to do is beat the bugger down with it until he can no longer stand on his feet.\
 Actually leaders and heroes are usually well protected so that what weapon you use does not matter.\
 However, your average rabble or bandit isn't as tough, so if you want to take prisoners from the regulars,\
 you musn't use anything other than blunt weapons.", "ramun_ask_about_capturing_2",[]],
  [trp_ramun_the_slave_trader,"ramun_have_blunt_weapon_no", [],
 "No? Heh, you are lucky then. I was thinking of replacing my old club with a new one.\
 It is not as in good condition as it used to be but it will still be useful to you if you are trying to get prisoners.\
 Here you may have it.","ramun_have_blunt_weapon_no_2",[(troop_add_item, "trp_player","itm_club",imod_cracked)]],
  [trp_ramun_the_slave_trader|plyr,"ramun_have_blunt_weapon_no_2", [],
 "Thanks Ramun. I guess this taking prisoners business will be easier than I expected.", "ramun_ask_about_capturing_3",[]],
  [trp_ramun_the_slave_trader,"ramun_ask_about_capturing", [],
 "Sure let me repeat the basics about capturing to you\
 If you want to capture someone alive you must avoid hitting him with sharp weapons and use a blunt weapon instead.\
 A hammer would do fine, or a blackjack or a good old club.\
 Actually leaders and heroes are usually well protected so that what weapon you use does not matter.\
 However, your average rabble or bandit isn't as tough, so if you want to take prisoners from the regulars, you must use blunt weapons.", "ramun_ask_about_capturing_2",[]],
  [trp_ramun_the_slave_trader|plyr,"ramun_ask_about_capturing_2", [], "Sounds easy enough. What else?", "ramun_ask_about_capturing_3",[]],
  [trp_ramun_the_slave_trader,"ramun_ask_about_capturing_3", [],
 "Actually, it is not that easy. Blunt weapons like clubs do less damage than sharp or edged weapons.\
 And trust me, given the chance, most of the scum you run across will sooner kill you than try to take you alive,\
 so don' t expect any courtesy when you pull out a club instead of a sword.\
 Moreover, having to drag prisoners to and fro will slow down your party.\
 For these reasons, some warriors do not bother to capture prisoners.\
 But of course, they are the ones who can turn down the extra money, right?", "ramun_ask_about_capturing_4",[]],
  [trp_ramun_the_slave_trader|plyr,"ramun_ask_about_capturing_4", [],
 "Is there anything else I need to know?", "ramun_ask_about_capturing_5",[]],
  [trp_ramun_the_slave_trader,"ramun_ask_about_capturing_5", [],
 "One final thing. If you want to capture many prisoners, you should know a thing or two about the skill of prisoner management.\
 Unless you personally know that skill, you cannot drag along prisoners with your party. You wouldn't want your prisoners to escape or stab you in your sleep now, would you?", "ramun_ask_about_capturing_7",[]],
  [trp_ramun_the_slave_trader|plyr,"ramun_ask_about_capturing_7", [],
 "Thanks, I will keep that in mind.", "ramun_pre_talk",[]],

  [trp_ramun_the_slave_trader|plyr,"ramun_talk", [], "I'd better be going.", "ramun_leave",[]],
  [trp_ramun_the_slave_trader,"ramun_leave", [], "Bring your prisoners straight to me. Remember. I pay well.", "close_window",[]],

  [trp_tournament_master,"start", [[neq,"$waiting_for_arena_fight_result"],[eq,"$zendar_arena_join_or_watch",0],[neq,"$arena_fight_won"]],
 "Congratulations champion. You made some pretty good moves out there. Here is your share of share of the prize money, 2 denars.", "arenamaster_fight",
   [[assign,"$waiting_for_arena_fight_result"],[add_xp_to_troop,20],[troop_add_gold, "trp_player",2]]],
  [trp_tournament_master,"start", [[neq,"$waiting_for_arena_fight_result"],[eq,"$zendar_arena_join_or_watch",0]],
 "That's quite the bruise you're sporting. But don't worry; everybody gets trounced once in awhile. The important thing is to pick yourself up, dust yourself off and keep fighting. That's what champions do.", "arenamaster_fight",[[assign,"$waiting_for_arena_fight_result"]]],
  [trp_tournament_master,"start", [[neq,"$waiting_for_arena_fight_result"]],
 "That was exciting wasn't it? Nothing like a good fight to get the blood flowing.", "arenamaster_fight",[[assign,"$waiting_for_arena_fight_result"]]],
  [trp_tournament_master,"start", [[eq, "$arenamaster_introduced"]], "Ah, a new face in the Zendar games. Welcome my {boy/girl}. I am the tournament master. Everything that happens in that arena is my business, and I do love every bit of it. I am the one you should talk to if you want to watch the games, or place a small bet for a little excitement. But wait, you are the kind who would rather participate than watch, right?", "arenamaster_introduce",[[assign,"$arenamaster_introduced",1]]],
  [trp_tournament_master|plyr,"arenamaster_introduce", [], "Can I participate?", "arenamaster_introduce_2",[]],
  [trp_tournament_master,"arenamaster_introduce_2", [], "Not only you can participate, but you should. The tournament ground is the place to be, the heart of Zendar! It is full of excitement and challange, and it is a great place to get experience. And while you are at it, you can make a small fortune by gambling on yourself too.", "arenamaster_introduce_3",[]],
  [trp_tournament_master|plyr,"arenamaster_introduce_3", [], "Sounds good. How do I participate?", "arenamaster_introduce_4",[]],
  [trp_tournament_master,"arenamaster_introduce_4", [], "Have you finished the training?", "arenamaster_introduce_5",[]],
  [trp_tournament_master|plyr,"arenamaster_introduce_5", [[ge,"$novice_training_difficulty",4]], "Yes I have.", "arenamaster_introduce_7a",[]],
  [trp_tournament_master|plyr,"arenamaster_introduce_5", [], "No I haven't.", "arenamaster_introduce_7b",[]],
  [trp_tournament_master,"arenamaster_introduce_7a", [], "Great then. You can participate in the games as you like.", "arenamaster_fight",[[assign,"$permitted_to_join_tournament",1]]],
  [trp_tournament_master,"arenamaster_introduce_7b", [], "I advise you to work on your skills with the trainer then. He's seen his share of battle and can teach you the basics of combat.\
 Jumping right into the tournament fights may be somewhat rough for you.\
 Of course you are welcome to watch the games whenever you like.", "arenamaster_chat_b",[]],
  [trp_tournament_master|plyr,"arenamaster_chat_b", [], "Maybe I'll just watch then.", "arenamaster_fight",[]],
  
  [trp_tournament_master,"start", [], "Well if it isn't {playername}. Good to see you again.", "arenamaster_fight",[]],

  [trp_tournament_master,"arenamaster_fight",
   [[eq,"$zendar_arena_join_or_watch",1],
    [ge,"$zendar_bet_amount",1],
    [assign,reg(0),"$zendar_winner_team"],[eq,"$zendar_arena_bet_team",reg(0)],
    [assign,reg(5),"$zendar_bet_amount"],[val_mul,reg(5),19],[val_div,reg(5),10]],
 "You've won the bet, eh? Let me see. The sum you have earned amounts to {reg5} denars. Here you go.", "arenamaster_fight",
   [[troop_add_gold, "trp_player",reg(5)],[assign,"$zendar_bet_amount"]]],
  
  [trp_tournament_master,"arenamaster_fight",
   [[eq,"$zendar_arena_join_or_watch",0],
    [ge,"$zendar_bet_amount",1],
    [neq,"$arena_fight_won"],
#    [put_cookie_to_reg,"zendar_winner_team",0],[eq,"zendar_arena_bet_team",reg(0)],
    [assign,reg(5),"$zendar_bet_amount"],
    [val_mul,reg(5),19],
    [val_div,reg(5),10]],
 "And you had the good sense to bet on yourself too. Hmm let me see. You have won yourself some {reg5} denars. Here you are.", "arenamaster_fight",
   [[troop_add_gold, "trp_player",reg(5)],[assign,"$zendar_bet_amount",0]]],

  [trp_tournament_master,"arenamaster_fight", [[eq,"$zendar_arena_game_type",0]], "The next fight will be a two vs. two\
 melee. I still need a fighter for the blue team. Are you interested?", "arenamaster_will_you_fight",
   [
    [assign,reg(10),"trp_regular_fighter"],
    [assign,reg(11),"trp_regular_fighter"],
    [assign,reg(12),"trp_veteran_fighter"],
    [assign,reg(13),"trp_veteran_fighter"],
    [assign,reg(14),"trp_veteran_fighter"],
    [assign,reg(15),"trp_champion_fighter"],
    [assign,reg(16),"trp_champion_fighter"],
    [assign,reg(17),"trp_xerina"],
    [assign,reg(18),"trp_dranton"],
    [assign,reg(19),"trp_kradus"],
    [shuffle_range,10,20],
    [modify_visitors_at_site,"scn_zendar_arena"],[reset_visitors],
#    [store_shuffled_range,8],
    [assign,reg(0),1],[assign,reg(1),2],[assign,reg(2),3],[assign,reg(3),4],[assign,reg(4),5],[assign,reg(5),6],[assign,reg(6),7],[assign,reg(7),8],
    [shuffle_range,0,8],
    [set_visitor,reg(0),reg(10)],
    [set_visitor,reg(1),reg(11)],
    [assign,reg(0),9],[assign,reg(1),10],[assign,reg(2),11],[assign,reg(3),12],[assign,reg(4),13],[assign,reg(5),14],[assign,reg(6),15],[assign,reg(7),16],
    [shuffle_range,0,8],
#    [set_visitor,reg(0),reg(12)],
    [set_visitor,reg(0),0],
    [assign,"$zendar_arena_player_position",reg(0)],
    [set_visitor,reg(1),reg(13)],
   ]],
  [trp_tournament_master,"arenamaster_fight", [[eq,"$zendar_arena_game_type",1]], "The next fight will be a three vs. three\
 melee. I still need a fighter for the red team. Are you interested?", "arenamaster_will_you_fight",
   [
    [assign,reg(10),"trp_regular_fighter"],
    [assign,reg(11),"trp_regular_fighter"],
    [assign,reg(12),"trp_veteran_fighter"],
    [assign,reg(13),"trp_veteran_fighter"],
    [assign,reg(14),"trp_veteran_fighter"],
    [assign,reg(15),"trp_champion_fighter"],
    [assign,reg(16),"trp_champion_fighter"],
    [assign,reg(17),"trp_xerina"],
    [assign,reg(18),"trp_dranton"],
    [assign,reg(19),"trp_kradus"],
    [shuffle_range,10,20],
    [modify_visitors_at_site,"scn_zendar_arena"],[reset_visitors],
    [assign,reg(0),1],[assign,reg(1),2],[assign,reg(2),3],[assign,reg(3),4],[assign,reg(4),5],[assign,reg(5),6],[assign,reg(6),7],[assign,reg(7),8],
    [shuffle_range,0,8],
    [set_visitor,reg(0),0],
    [assign,"$zendar_arena_player_position",reg(0)],
    [set_visitor,reg(1),reg(10)],
    [set_visitor,reg(2),reg(11)],
    [assign,reg(0),9],[assign,reg(1),10],[assign,reg(2),11],[assign,reg(3),12],[assign,reg(4),13],[assign,reg(5),14],[assign,reg(6),15],[assign,reg(7),16],
    [shuffle_range,0,8],
    [set_visitor,reg(0),reg(12)],
    [set_visitor,reg(1),reg(13)],
    [set_visitor,reg(2),reg(14)],
   ]],
#  [tournament_master,"arenamaster_fight", [], "The next fight will start soon. Do you want to participate?", "arenamaster_will_you_fight",[]],
  [trp_tournament_master|plyr,"arenamaster_will_you_fight", [[ge,"$novice_training_difficulty",0]], #should be 4.
   "I want to join the fight.", "arenamaster_we_will_fight",
   [[assign,"$zendar_arena_join_or_watch",0]]],
  [trp_tournament_master|plyr,"arenamaster_will_you_fight", [], "I would like to watch the fight.", "arenamaster_we_will_watch",
   [[assign,"$zendar_arena_join_or_watch",1],
    [set_visitor,"$zendar_arena_player_position","trp_veteran_fighter"],
    [set_visitor,0,0],
  ]],
  [trp_tournament_master|plyr,"arenamaster_will_you_fight", [], "No. perhaps later.", "arenamaster_we_will_fight_not",[]],
  [trp_tournament_master,"arenamaster_we_will_fight_not", [], "Allright. Talk to me when you are ready.", "close_window",[]],
  [trp_tournament_master,"arenamaster_we_will_fight", [], "Do you want to place a bet on yourself?", "arenamaster_will_you_bet",
   [[assign,"$zendar_bet_amount"],[assign,"$zendar_arena_bet_team",0],
  ]],
  [trp_tournament_master|plyr,"arenamaster_will_you_bet", [], "No.", "arenamaster_start_fight",[]],
  [trp_tournament_master|plyr,"arenamaster_will_you_bet", [[store_troop_gold,reg(0)],[ge,reg(0),5]], "I want to bet 5 denars.",
   "arenamaster_bet_placed",[[assign,"$zendar_bet_amount",5],[troop_remove_gold, "trp_player",5]]],
  [trp_tournament_master|plyr,"arenamaster_will_you_bet", [[store_troop_gold,reg(0)],[ge,reg(0),15]], "I want to bet 15 denars.",
   "arenamaster_bet_placed",[[assign,"$zendar_bet_amount",15],[troop_remove_gold, "trp_player",15]]],
  [trp_tournament_master|plyr,"arenamaster_will_you_bet", [[store_troop_gold,reg(0)],[ge,reg(0),30]], "I want to bet 30 denars.",
   "arenamaster_bet_placed",[[assign,"$zendar_bet_amount",30],[troop_remove_gold, "trp_player",30]]],
  [trp_tournament_master,"arenamaster_we_will_watch", [[eq,"$watching_tip_given"]],
   "Good. I believe you will enjoy watching the tournament. [Tip: You can press and hold down shift key to zoom in and have a better view of the action while you watch.]", "arenamaster_we_will_watch",[[assign,"$watching_tip_given",1]]],
  [trp_tournament_master,"arenamaster_we_will_watch", [], "Do you want to place a bet?", "arenamaster_will_you_bet",[]],
  [trp_tournament_master,"arenamaster_bet_placed", [[eq,"$zendar_arena_join_or_watch",1]], "Hmm. That's good. And which team do you want to place your bet on.", "arenamaster_select_team",[]],
  [trp_tournament_master|plyr,"arenamaster_select_team", [], "The red team. I have a feeling they will win this one.",
   "arenamaster_start_fight",[[assign,"$zendar_arena_bet_team",0]]],
  [trp_tournament_master|plyr,"arenamaster_select_team", [], "The blue team. They will sweep the ground with the reds.",
   "arenamaster_start_fight",[[assign,"$zendar_arena_bet_team",1]]],
  [trp_tournament_master,"arenamaster_bet_placed", [], "That's good. Let me record that.", "arenamaster_start_fight",[]],
  
  [trp_tournament_master,"arenamaster_start_fight",
   [], "Very well. The fight starts in a moment. Good luck.", "close_window",
   [[assign,"$arena_fight_won"],
    [assign,"$zendar_winner_team",-1],
    [assign,"$waiting_for_arena_fight_result",1],
    [assign,reg(0),"$zendar_arena_game_type"],
    [store_add, reg(0), reg(0),1],
    [val_mod,reg(0),2],
    [assign,"$zendar_arena_game_type",reg(0)],
    [set_jump_mission,"mt_zendar_arena_fight"],
    [jump_to_scene,"scn_zendar_arena"]]],

  [trp_trainer,"start", [[eq,"$novicemaster_introduced"]], "I am the trainer of Zendar. Every new soldier, arena hopeful or mercenary that passes through here talks to me. If you want to take part in the tournaments you'd better finish training with me first. I don't even charge money to newcomers so you don't even need worry about the pay. Train until your muscles ache, I always say, and you will pick the rewards soon enough. What is your name?", "novicemaster_introduce",
   [[assign,"$novicemaster_introduced",1],
    [assign,"$novice_training_difficulty"],
    [assign,"$num_opponents_to_beat_in_a_row",3],
    [assign,"$novicemaster_opponent_troop","trp_novice_fighter"],
  ]],
  [trp_trainer|plyr,"novicemaster_introduce", [], "{playername}.", "novicemaster_introduce_2",[]],
  [trp_trainer,"novicemaster_introduce_2", [], "Well met, {playername}. You want to take part in the tournaments right?", "novicemaster_introduce_3",[]],
  [trp_trainer|plyr,"novicemaster_introduce_3", [], "I guess so.", "novicemaster_introduce_4",[]],
  [trp_trainer,"novicemaster_introduce_4", [], "Good. Then let us start right away. But before you step into the training ground, I want to tell you about the basics of combat. These are going to mean the difference between a stack of denars and a busted skull, so listen carefully.", "novicemaster_introduce_5",[]],
  [trp_trainer|plyr,"novicemaster_introduce_5", [], "I am listening.", "novicemaster_tell_theory",[]],
  [trp_trainer,"novicemaster_tell_theory", [], "Allright. The first thing you should know as a fighter is how to defend yourself. Keeping damage away from yourself is the first rule of combat, and it is much more important than delivering damage to others. Everybody can swing a sword around and hope to cut a few limbs along the way, but only expert defenders live to tell of it.",
	"novicemaster_tell_theory_2",[]],
  [trp_trainer,"novicemaster_tell_theory_2", [], "Now. Defending yourself is easiest if you are equipped with a shield.\
 Just block with your shield. [Hold down the right mouse button to defend yourself with the shield.] In this state, you will be able to deflect all attacks that come from your front. However, you will still be open to strikes from your sides or your back.", "novicemaster_tell_theory_3",[]],
  [trp_trainer|plyr,"novicemaster_tell_theory_3", [], "What if I don't have shield?", "novicemaster_tell_theory_4",[]],
  [trp_trainer,"novicemaster_tell_theory_4", [], "Then you will have to use your weapon to block your opponent. This is a bit more difficult than defending with a shield. Defending with a weapon, you can block against only ONE attack direction.\
 That is, you block against either overhead swings, side swings or thrusts. Therefore you must watch your opponent carefully and start to block AFTER he starts his attack. In this way you will be able to block against the direction of his current attack. If you start to block BEFORE he makes his move, he may just attack in another direction than the one you are blocking against and score a hit.", "novicemaster_tell_theory_5",[]],
  [trp_trainer|plyr,"novicemaster_tell_theory_5", [], "What about attacking?", "novicemaster_tell_theory_6",[]],
  [trp_trainer,"novicemaster_tell_theory_6", [], "The most important thing about attacking is maintaing your control and fighting calmly... [Basically pressing and holding down the left mouse button readies an attack and releasing the left mouse button starts the attack.]", "novicemaster_tell_theory_7",[]],
  [trp_trainer,"novicemaster_tell_theory_7", [], "After all this talking, you must be anxious to fight eh?", "novicemaster_talk",[]],
 
  [trp_trainer,"start", [[neq,"$waiting_for_training_fight_result"],[neq,"$training_fight_won"]],
 "That was a good fight. ", "novicemaster_enter_fight",[[val_add,"$num_opponents_to_beat_in_a_row",-1],[assign,"$waiting_for_training_fight_result"]]],
  [trp_trainer,"start", [[neq,"$waiting_for_training_fight_result"]],
 "Ha! Looks like you've developed a bit of a limp there. Don't worry, even losses have their value, provided you learn from them. Shake the stars out of your eyes and get back in there. There's no other way to win.", "novicemaster_enter_fight",[[assign,"$num_opponents_to_beat_in_a_row",3],[assign,"$waiting_for_training_fight_result"]]],
  [trp_trainer,"start", [], "Hello {playername}. Ready for more training?", "novicemaster_talk",[]],
#  [trainer,"novicemaster_pre_talk", [], "Yes?", "novicemaster_talk",[]],
  [trp_trainer|plyr,"novicemaster_talk", [], "Yes, training is what I need.", "novicemaster_enter_fight",[]],
  [trp_trainer|plyr,"novicemaster_talk", [], "Before that, can you go over the basics of combat once again?", "novicemaster_tell_theory",[]],
  [trp_trainer|plyr,"novicemaster_talk", [], "I need to leave now. I'll train another time.", "novicemaster_not_ready",[]],

  [trp_trainer,"novicemaster_enter_fight", [[eq,"$training_system_explained"]],
 "The training has four tiers, each tougher than the one before.\
 To finish a tier and advance to the next one, you have to win three fights in a row. Good luck.", "novicemaster_enter_fight",[[assign,"$training_system_explained",1]]],
  [trp_trainer,"novicemaster_enter_fight",
   [[ge,"$novice_training_difficulty",4]],
 "You have passed all stages of training. But if you want you can still practice. Are you ready?", "novicemaster_are_you_ready",
   [[assign,"$num_opponents_to_beat_in_a_row",9999]]],
  [trp_trainer,"novicemaster_enter_fight",
   [[eq,"$num_opponents_to_beat_in_a_row",0],[eq,"$novice_training_difficulty",0]],
 "Way to go {lad/lass}. With this victory, you have advanced to the next training level. From now on your opponents will be regular fighters, not the riff-raff off the street, so be on your toes.",
   "novicemaster_enter_fight",
   [[assign,"$num_opponents_to_beat_in_a_row",3],
    [val_add,"$novice_training_difficulty",1],
    [add_xp_to_troop,100],
    [assign,"$novicemaster_opponent_troop","trp_regular_fighter"]]],
  [trp_trainer,"novicemaster_enter_fight",
   [[eq,"$num_opponents_to_beat_in_a_row",0],[eq,"$novice_training_difficulty",1]],
 "Way to go {lad/lass}. Welcome to the third training level. From now on your opponents will be veteran fighters; soldiers and arena regulars and the like. These guys know some dirty tricks, so keep your defense up.",
   "novicemaster_enter_fight",
   [[assign,"$num_opponents_to_beat_in_a_row",3],
    [val_add,"$novice_training_difficulty",1],
    [add_xp_to_troop,100],
    [assign,"$novicemaster_opponent_troop","trp_veteran_fighter"]]],
  [trp_trainer,"novicemaster_enter_fight",
   [[eq,"$num_opponents_to_beat_in_a_row",0],[eq,"$novice_training_difficulty",2]],
 "You've got the heart of a champion, {lad/lass}, and the sword arm to match. From now on your opponents will be champion fighters.\
 These are the cream of crop, the best soldiers and arena title-holders Zendar has to offer. If you can best three of them in a row, you will join their ranks.",
   "novicemaster_enter_fight",
   [[assign,"$num_opponents_to_beat_in_a_row",3],
    [val_add,"$novice_training_difficulty",1],
    [add_xp_to_troop,100],
    [assign,"$novicemaster_opponent_troop","trp_champion_fighter"]]],
  [trp_trainer,"novicemaster_enter_fight",
   [[eq,"$num_opponents_to_beat_in_a_row",0],[eq,"$novice_training_difficulty",3]],
 "It does my heart good to see such a promising talent. You have passed all tiers of training. You can now tell everyone that you have been trained by the trainer of Zendar.",
   "novicemaster_finish_training",
   [[assign,"$num_opponents_to_beat_in_a_row",3],
    [val_add,"$novice_training_difficulty",1],
    [add_xp_to_troop,300]]],
  [trp_trainer|plyr,"novicemaster_finish_training", [], "Thank you master.", "novicemaster_finish_training_2",[]],
  [trp_trainer,"novicemaster_finish_training_2", [], "I wish you good luck in the tournaments. And, don't forget,\
  if you want to practice your swordwork anytime, just come and say the word.", "close_window",[]],
  [trp_trainer,"novicemaster_enter_fight",
   [[assign,reg(8),"$num_opponents_to_beat_in_a_row"],[assign,reg(9),"$novicemaster_opponent_troop"],[str_store_troop_name,9,reg(9)]],
 "Your next opponent will be a {s9}. You need to win {reg8} more\
 fights in a row to advance to the next tier. Are you ready?", "novicemaster_are_you_ready",
   []],
  [trp_trainer|plyr,"novicemaster_are_you_ready", [], "Yes I am.", "novicemaster_ready_to_fight",[]],
  [trp_trainer,"novicemaster_ready_to_fight",
   [[assign,reg(9),"$novicemaster_opponent_troop"]], "Here you go then. Good luck.", "close_window",
   [[assign,"$training_fight_won",0],
    [assign,"$waiting_for_training_fight_result",1],
    [modify_visitors_at_site,"scn_novice_ground"],[reset_visitors],
#    [store_shuffled_range,4],
    [assign,reg(0),0],
    [assign,reg(1),1],
    [assign,reg(2),2],
    [assign,reg(3),3],
    [shuffle_range,0,4],
    [set_visitor,reg(0),0],
    [set_visitor,reg(1),reg(9)],
    [set_jump_mission,"mt_zendar_training_fight"],
    [jump_to_scene,"scn_novice_ground"]]],

  [trp_trainer|plyr,"novicemaster_are_you_ready", [], "Just a minute. I am not ready yet.", "novicemaster_not_ready",[]],
  [trp_trainer,"novicemaster_not_ready", [], "Hey, You will never make it if you don't practice.", "close_window",[]],


  [trp_xerina|plyr,"start", [[eq,"$xerina_introduced"]], "Hello. You are one of the fighters in the games aren't you?", "xerina_introduce",[[assign,"$xerina_introduced",1]]],
  [trp_xerina,"xerina_introduce", [], "Yes. I am Xerina.", "xerina_introduce_2",[]],
  [trp_xerina|plyr,"xerina_introduce_2", [], "I am surprised to see {a/another} woman in the tournaments. It seems to be a men's game.", "xerina_introduce_3",[]],
  [trp_xerina,"xerina_introduce_3", [], "Men's game? I beat the hell out of the men out there {/sweetie}. And the spectators love me for it.", "xerina_introduce_4",[]],
  [trp_xerina|plyr,"xerina_introduce_4", [], "But aren't you worried that you will get injured, or worse killed?", "xerina_introduce_5",[]],
  [trp_xerina,"xerina_introduce_5", [], "The tournament fights are not so dangerous if you do things right.\
 There are physicians that take care of your wounds after the fight, and of course the weapons used are not lethal.\
 They deliver blunt damage only.", "xerina_introduce_6",[]],
  [trp_xerina|plyr,"xerina_introduce_6", [], "Blunt damage? What is that?", "xerina_introduce_7",[]],
  [trp_xerina,"xerina_introduce_7", [], "Weapon damage has three different kinds: Cut, pierce and blunt.\
 Weapons like axes and sabres deliver cut damage. Cutting weapons are the most basic and common.\
 Weapons like spears and lances deliver piercing damage.\
 Piercing damage is more effective against armor than cut damage.\
 Lastly, weapons like clubs deliver blunt damage. Blunt damage will knock an opponent unconscious rather than killing him, which is useful if you have need of him after a fight.\
 Some weapons deliver different kinds of damage with different kind of attacks.\
 For example a long sword will deliver piercing damage when thrust but cut damage when swung.", "xerina_introduce_8",[]],
  [trp_xerina|plyr,"xerina_introduce_8", [], "That was quite helpful. Thanks.", "xerina_introduce_9",[]],
  [trp_xerina,"xerina_introduce_9", [], "See you on the tournament ground. And good luck.\
 You will need it if you face me.", "close_window",[]],

  [trp_xerina,"start",[],"Hello {playername}.","xerina_talk",[]],
  [trp_xerina|plyr,"xerina_talk", [], "Can you repeat what you told me about damage types?", "xerina_introduce_7",[]],
  [trp_xerina|plyr,"xerina_talk", [], "I have to leave now. Good luck to you in the games.", "close_window",[]],

  [trp_dranton,"start",[],"Leave me alone.","close_window",[]],

  [trp_kradus|plyr,"start", [[eq,"$kradus_introduced"]], "Hello. You must be one of the fighters in the games.", "kradus_introduce",[[assign,"$kradus_introduced",1]]],
  [trp_kradus,"kradus_introduce", [], "One of the fighters? I am Kradus. Don't tell me you don't know my name.", "kradus_introduce_2",[]],
  [trp_kradus|plyr,"kradus_introduce_2", [], "Have you been fighting in the tournaments for long?", "kradus_introduce_3",[]],
  [trp_kradus,"kradus_introduce_3", [], "Long? I was a champion when the arena was nothing more than a ring of dirt, and your only spectators were the sorry-looking horses waiting their turn.", "kradus_introduce_4",[]],
  [trp_kradus|plyr,"kradus_introduce_4", [], "Could you give me a few hints about fighting?", "kradus_introduce_5",[]],
  [trp_kradus,"kradus_introduce_5", [], "I suppose there would be no harm in that. After all, what is a champion when there are no decent challengers? My favourite weapon is the lance. Give me a lance and the match is over before it starts. Want to know why?", "kradus_introduce_6",[]],
  [trp_kradus|plyr,"kradus_introduce_6", [], "Sure.", "kradus_introduce_7",[]],
  [trp_kradus,"kradus_introduce_7", [], "The lance is a purely offensive weapon. You can't use it for blocking enemy attacks, but in the right hands, they won't have a chance to swing anyway,\
 as it has a longer reach than any other weapon.\
 The best way to use the lance though is couching it under your arm while charging on horse back.\
 Once your horse gains speed in this state, its full power concentrates on the tip of the lance.\
 Nothing will stand before the destructive power of the couched lance. It will pierce and shatter shields\
 and deliver great damage to anyone unfortunate enough to be on its way.", "kradus_introduce_8",[]],
  [trp_kradus|plyr,"kradus_introduce_8", [], "Sounds powerful indeed. What if you are on the receiving end of the couched lance? What would you do to defend yourself?", "kradus_introduce_9",[]],
  [trp_kradus,"kradus_introduce_9", [], "You cannot block it obviously, neither with a sword nor a shield.\
 The best defense is to stand at a spot where your opponent's horse cannot come to you at a full gallop,\
 like the top of a hill or behind a thick tree. If you are out on the open, the best defensive strategy is to run sideways\
 hoping that your opponent cannot maneuver to hit you.", "kradus_introduce_10",[]],
  [trp_kradus|plyr,"kradus_introduce_10", [], "Well thanks a lot. That was really helpful.", "kradus_introduce_11",[]],
  [trp_kradus,"kradus_introduce_11", [], "Good luck at the tournament ground.", "close_window",[]],

  [trp_kradus,"start", [], "Hello {playername}. I hope you are doing well.", "kradus_talk",[]],
  [trp_kradus|plyr,"kradus_talk", [], "Can you tell me about the couched lance again?", "kradus_introduce_7",[]],
  [trp_kradus|plyr,"kradus_talk", [], "Thanks Kradus. I'll see you later.", "close_window",[]],

  [party_tpl|pt_peasant,"start", [], "Greetings traveller.", "peasant_talk_1",[(play_sound,"snd_encounter_farmers")]],
  [party_tpl|pt_peasant|plyr,"peasant_talk_1", [[eq,"$quest_accepted_zendar_river_pirates"]], "Greetings to you too.", "close_window",[(assign, "$g_leave_encounter",1)]],
  [party_tpl|pt_peasant|plyr,"peasant_talk_1", [[neq,"$quest_accepted_zendar_river_pirates"],[eq,"$peasant_misunderstanding_said"]], "I have been charged with hunting down outlaws in this area...", "peasant_talk_2",[[assign,"$peasant_misunderstanding_said",1]]],
  [party_tpl|pt_peasant|plyr,"peasant_talk_1", [[neq,"$quest_accepted_zendar_river_pirates"],[neq,"$peasant_misunderstanding_said"]], "Greetings. I am hunting outlaws. Have you seen any around here?", "peasant_talk_2b",[]],
  [party_tpl|pt_peasant,"peasant_talk_2", [], "I swear to God {sir/madam}. I am not an outlaw... I am just a simple peasant. I am taking my goods to the market, see.", "peasant_talk_3",[]],
  [party_tpl|pt_peasant|plyr,"peasant_talk_3", [], "I was just going to ask if you saw any outlaws around here.", "peasant_talk_4",[]],
  [party_tpl|pt_peasant,"peasant_talk_4", [], "Oh... phew... yes, outlaws are everywhere. They are making life miserable for us.\
 I pray to God you will kill them all.", "close_window",[(assign, "$g_leave_encounter",1)]],
  [party_tpl|pt_peasant,"peasant_talk_2b", [], "Outlaws? They are everywhere. They are making life miserable for us.\
 I pray to God you will kill them all.", "close_window",[(assign, "$g_leave_encounter",1)]],

  [party_tpl|pt_manhunters,"start", [], "You seen any outlaws around here?", "manhunter_talk_b",[]],
  [party_tpl|pt_manhunters|plyr,"manhunter_talk_b", [], "Yes they went this way an hour ago.", "manhunter_talk_b1",[]],
  [party_tpl|pt_manhunters,"manhunter_talk_b1", [], "Bastards. Come on boys lets go get them. Thanks a lot friend.", "close_window",[(assign, "$g_leave_encounter",1)]],
  [party_tpl|pt_manhunters|plyr,"manhunter_talk_b", [], "No. Sorry. Haven't seen any outlaws lately.", "manhunter_talk_b2",[]],
  [party_tpl|pt_manhunters,"manhunter_talk_b2", [], "Those bastards hide from us like little rats.\
 But we'll get them sooner or later.", "close_window",[(assign, "$g_leave_encounter",1)]],

  [party_tpl|pt_manhunters,"start", [[store_character_level,reg(1)],[lt,reg(1),4]], "Halt. We are hunting down outlaws in this region.", "manhunter_talk_1",[]],
  [party_tpl|pt_manhunters|plyr,"manhunter_talk_1", [], "Good luck to you. Now if you'll excuse me I have to leave.", "manhunter_talk_2",[]],
  [party_tpl|pt_manhunters,"manhunter_talk_2", [], "Stop right there. How do we know that you are not an outlaw?", "manhunter_talk_3",[]],
  [party_tpl|pt_manhunters|plyr,"manhunter_talk_3", [[lt,"$manhunter_trial",3]], "Please sir, I am not an outlaw... let me go.", "manhunter_talk_4a",[]],
  [party_tpl|pt_manhunters,"manhunter_talk_4a", [], "A weasel like you can't possibly be an outlaw. Get lost.", "close_window",[(assign, "$g_leave_encounter",1)]],
  [party_tpl|pt_manhunters|plyr,"manhunter_talk_3", [[eq,"$manhunter_trial",0]], "How do I know you are not an outlaw yourself?", "manhunter_talk_4b",[]],
  [party_tpl|pt_manhunters|plyr,"manhunter_talk_3", [[eq,"$manhunter_trial",1]], "How you would know anything is a mystery to me.", "manhunter_talk_4b",[]],
  [party_tpl|pt_manhunters|plyr,"manhunter_talk_3", [[ge,"$manhunter_trial",2]], "If I were an outlaw, I would be running away from you, right?", "manhunter_talk_4c",[]],
  [party_tpl|pt_manhunters,"manhunter_talk_4b", [], "Are you trying to be smart with me? That's a big mistake. Boys, the {man/girl} is an outlaw. Kill {him/her}.", "close_window",[[add_xp_to_troop,100],[val_add,"$manhunter_trial",1],[encounter_attack]]],
  [party_tpl|pt_manhunters,"manhunter_talk_4c", [], "Yeah... right. Outlaws run away from us like mad. You can't possibly be an outlaw. Sorry to disturb you friend. You may go.", "close_window",[[val_add,"$manhunter_trial",1],(assign, "$g_leave_encounter",1)]],

  [party_tpl|pt_river_pirates,"start", [], "I will have your valuables, or your life. Your choice.", "river_pirates_1",[(play_sound,"snd_encounter_river_pirates")]],
  [party_tpl|pt_river_pirates|plyr,"river_pirates_1", [[store_character_level,reg(1)],[lt,reg(1),4]], "I am not afraid of you. I will fight.", "close_window",
   [[encounter_attack]]],
  [party_tpl|pt_river_pirates|plyr,"river_pirates_1", [[store_character_level,reg(1)],[ge,reg(1),4]], "You will have nothing of mine. Except the tip of my sword... in your heart.", "close_window",
   [[encounter_attack]]],








  [trp_town_13_ruler_b|plyr,"governer_talk", [[neq,"$borcha_introduced"],[eq,"$borcha_taken_prisoner"]], "About the man in the cell...", "gruham_about_borcha",[]],
  [anyone,"gruham_about_borcha", [[eq,"$kg_tell_borcha"]],
   "The prisoner? He's a horse thief. He attempted to steal a pack of my horses, can you believe that?\
 But the fool had been drinking all evening, appearently to build up his courage, and by the time he got to the job, he was pitch drunk.\
 Still he managed to drive the horses out before the guards could close the gate, luckily my men found him passed out under a tree just a few miles off the town.", "gruham_about_borcha_2",[[assign,"$kg_tell_borcha",1]]],
  [anyone,"gruham_about_borcha", [],
   "Did you consider my offer?", "gruham_about_borcha_10",[]],
  [anyone|plyr,"gruham_about_borcha_2", [], "What are you going to do about him?", "gruham_about_borcha_3",[]],
  [anyone,"gruham_about_borcha_3", [], "Normally I have horse thieves hanged right away, but this one claims that\
 there is a bounty on him in Sargoth and he is wanted alive so that he can be fittingly beaten and tortured before\
 the final punishment. Well in that case hanging him here could harm justice in Sargoth. One could think he made up\
 that story to buy himself a few more days, but of course, a simple horse thief like him can't be making up such elaborate lies.", "gruham_about_borcha_4",[]],
  [anyone|plyr,"gruham_about_borcha_4", [], "Of course... How much did he say the reward is?", "gruham_about_borcha_5",[]],
  [anyone,"gruham_about_borcha_5", [], "200 denars. But I cannot send him over to Sargoth myself.\
 We are, after all, at war with the Swadians.\
 Speaking of which, maybe an adventurer like you can help me with him...", "gruham_about_borcha_6",[]],
  [anyone|plyr,"gruham_about_borcha_6", [], "Me?", "gruham_about_borcha_7",[]],
  [anyone,"gruham_about_borcha_7", [], "Well, you could take him to Sargoth and claim his bounty.\
 You pay me just 100 denars now for the trouble I have taken and you can keep the bounty money for yourself.\
 You would see that the justice is served and make a nice profit off it along the way.", "gruham_about_borcha_8",[]],
  [anyone|plyr,"gruham_about_borcha_8", [], "I really don't know.", "gruham_about_borcha_9",[]],
  [anyone,"gruham_about_borcha_9", [], "All right. just pay me 50, but that's my final offer.", "gruham_about_borcha_10",[]],
  [anyone|plyr,"gruham_about_borcha_10", [], "Let me think about this for a while.", "gruham_about_borcha_think",[]],
  [anyone|plyr,"gruham_about_borcha_10", [], "All right, I accept your offer.", "gruham_about_borcha_11", []],
  [anyone,"gruham_about_borcha_11", [[store_troop_gold,reg(0)],[lt,reg(0),50]], "Hmm. But you don't have 50 denars do you?\
 Why don't you go earn some money? Perhaps you could try catching a few outlaws.", "close_window",[]],
  [anyone,"gruham_about_borcha_11", [[neg|hero_can_join_as_prisoner]], "Hmm. But you cannot manage any more prisoners at the moment.\
 Perhaps you should work on your prisoner management skill. Anyway, talk to me again when you have solved this.", "close_window",[]],
  [anyone,"gruham_about_borcha_11", [], "Excellent. I will keep the thief for you until you leave. And be careful on the way.", "close_window",
   [[troop_remove_gold, "trp_player",50],[assign,"$borcha_taken_prisoner",1],[troop_join_as_prisoner,"trp_borcha"],[remove_troop_from_site,"trp_borcha"]]],
  [anyone,"gruham_about_borcha_think", [], "It's your call. I'll wait, but don't be surprised if someone else takes up this opportunity in the meantime.", "close_window",[]],

  [trp_borcha,"start", [(eq,"$borcha_freed",1),
                        (neg|main_party_has_troop,"trp_borcha"),
                        (neq, "$g_encountered_party", "p_four_ways_inn"),],
   "Do you want me to rejoin you?", "member_wilderness_talk",[]],
  [trp_borcha,"start", [(neg|main_party_has_troop,"trp_borcha"),(eq, "$g_encountered_party", "p_four_ways_inn")], "Do you want me to rejoin you?", "member_inn_talk",[]],
  [trp_borcha,"member_separate_inn", [], "I don't know what you will do without me, but you are the boss. I'll wait for you at the Four Ways inn.", "close_window",
   [[store_conversation_troop,reg(0)],[remove_member_from_party,reg(0)],[add_troop_to_site, reg(0), "scn_four_ways_inn", borcha_inn_entry]]],

  [trp_borcha,"start", [[eq,"$borcha_introduced"]], "Hello young master. Do you have anything to eat? The guards here think I can live on cold water alone.", "borcha_introduce_1",[[assign,"$borcha_introduced",1]]],
  [trp_borcha|plyr,"borcha_introduce_1", [], "What crime did you accomplish to end up here?", "borcha_introduce_2",[]],
  [trp_borcha,"borcha_introduce_2", [], "Crime? I didn't do any crime... The Count's horses looked fat and in need of exercise, so I decided to take them for a ride. Just to put them back into shape a little. But the soldiers caught me and locked me up here.", "borcha_introduce_3",[]],
  [trp_borcha|plyr,"borcha_introduce_3", [], "Ah, they must have mistaken you for a horse thief.", "borcha_introduce_4",[]],
  [trp_borcha,"borcha_introduce_4", [], "Yes, it must be that... Well I am sure they will understand their mistake soon.", "borcha_introduce_5",[]],
  [trp_borcha|plyr,"borcha_introduce_5", [], "Yes, I'm sure they will.", "close_window",[]],
  [trp_borcha,"start", [], "Yes?", "borcha_cell_talk",[]],
  [trp_borcha|plyr,"borcha_cell_talk", [], "Nothing. Good-bye.", "close_window",[]],

  [trp_borcha,"event_triggered", [[neq,"$borcha_arrive_sargoth_as_prisoner"]], "Eh, we have arrived at Sargoth.", "borcha_arrive_sargoth",[[assign,"$borcha_arrive_sargoth_as_prisoner"]]],
  [trp_borcha|plyr,"borcha_arrive_sargoth", [], "Yes it's time to hand you to the authorities and collect my bounty money.", "borcha_arrive_sargoth_2",[]],
  [trp_borcha,"borcha_arrive_sargoth_2", [], "Boss, I thought you would have let go of the bounty money by now.", "borcha_arrive_sargoth_3",[]],
  [trp_borcha|plyr,"borcha_arrive_sargoth_3", [], "Let go of it? Is there a prize on your head in Sargoth or is there not?", "borcha_arrive_sargoth_4",[]],
  [trp_borcha,"borcha_arrive_sargoth_4", [], "I don't know... There has been a long time. Maybe the authorities have forgetten about it.", "borcha_arrive_sargoth_5",[]],
  [trp_borcha|plyr,"borcha_arrive_sargoth_5", [], "You lying bastard! There was no prize on your head wasn't it. You were making it all up to save your neck you rotten lying thief!", "borcha_arrive_sargoth_6",[]],
  [trp_borcha,"borcha_arrive_sargoth_6", [], "Calm down boss.", "borcha_arrive_sargoth_7",[]],
  [trp_borcha|plyr,"borcha_arrive_sargoth_7", [], "Calm down! I lost 100 denars because of you!", "borcha_arrive_sargoth_8",[]],
  [trp_borcha,"borcha_arrive_sargoth_8", [], "It was just 50. And I can make it up to you. Just take me in your service, give me a chance to repay my debt.", "borcha_prisoner_34",[]],

  [trp_borcha,"event_triggered", [[eq,"$borcha_asked_for_freedom"]], "Hey boss.", "borcha_prisoner_1",[]],
  [trp_borcha|plyr,"borcha_prisoner_1", [], "I'm not your boss. Now what is it?", "borcha_prisoner_2",[[assign,"$borcha_asked_for_freedom",1]]],
  [trp_borcha,"borcha_prisoner_2", [], "I was thinking... these mountains are dangerous. Why don't you give me a sword or a knife. I would guard your back.", "borcha_prisoner_3",[]],
  [trp_borcha|plyr,"borcha_prisoner_3", [], "Guard my back? You would stab me the moment I turned my back to you.", "borcha_prisoner_4",[]],
  [trp_borcha,"borcha_prisoner_4", [], "Ah, come on now. You saved me from that stinking cell in Rivacheg.\
 Do you think I would repay you like that. I am trying to look out for you.", "borcha_prisoner_5",[]],
  [trp_borcha|plyr,"borcha_prisoner_5", [], "Well keep doing that. I will deliver you to Sargoth where you will be hanged as you deserve and I will get my bounty money.", "borcha_prisoner_6",[]],
  [trp_borcha,"borcha_prisoner_6", [], "Oh the bounty money... Yes.", "borcha_prisoner_7",[]],
  [trp_borcha|plyr,"borcha_prisoner_7", [], "What? Is that a lie too. I can take you right back to Rivacheg if it is.", "borcha_prisoner_8",[]],
  [trp_borcha,"borcha_prisoner_8", [], "Of course it is not a lie. What do you take me for?... Just.. if it is gold you are after, I can help you make much more than the bounty money.", "borcha_prisoner_9",[]],
  [trp_borcha|plyr,"borcha_prisoner_9", [], "Yes yes. I am sure you are now planning to steal half of the horses in Calradia, but no thanks, I am not interested.", "borcha_prisoner_10",[]],
  [trp_borcha,"borcha_prisoner_10", [], "Horses? Who is talking about stealing horses? We could do much bigger things. I know all the paths and shortcuts in these lands. Think of it, you and me together, we could get ourselves a band and...", "borcha_prisoner_11",[]],
  [trp_borcha|plyr,"borcha_prisoner_11", [], "Ho, slow down there. We are not getting ourselves a band or anything.\
 We will go Sargoth and you will get hanged and that's it.", "borcha_prisoner_12",[]],
  [trp_borcha,"borcha_prisoner_12", [], "Well then. It's your call. We could become rich. But instead you will walk right into a bandit's trap without a scout's lead, and we will both end up dead. Some barren cliff will be our grave.", "borcha_prisoner_13",[]],
  [trp_borcha|plyr,"borcha_prisoner_13", [], "Thanks for the cheerful talk. Now shut up. I have enough things to worry about without you blattering.", "close_window",[]],

  [trp_borcha,"event_triggered", [], "Yes boss.", "borcha_prisoner_30",[]],
  [trp_borcha|plyr,"borcha_prisoner_30", [], "Are you really that good at scouting?", "borcha_prisoner_31",[]],
  [trp_borcha,"borcha_prisoner_31", [], "Damned good at it. I can smell the wind, read the movements of the birds.\
 I can tell what a man was thinking about by merely glancing at the tracks he left.\
 And I can teach you too.", "borcha_prisoner_32",[]],
  [trp_borcha|plyr,"borcha_prisoner_32", [], "No kidding.", "borcha_prisoner_33",[]],
  [trp_borcha,"borcha_prisoner_33", [], "Come on boss. A tough {man/woman} like you and a master scout like me.\
 We could do anything. This land is full of opportunities.", "borcha_prisoner_34",[]],
  [trp_borcha|plyr,"borcha_prisoner_34", [], "[Set him free]", "borcha_prisoner_34a",[]],
  [trp_borcha|plyr,"borcha_prisoner_34a", [], "All right, I'll give you a try. But try to do anything stupid and you'll find yourself at the hanging post before you know it.", "borcha_prisoner_set_free",[]],
  [trp_borcha,"borcha_prisoner_set_free", [[neg|hero_can_join]], "Darn, you can't lead any more troops at the moment boss. But don't forget your promise. Just make some room at the party for me and tell me when you are ready.", "close_window",[]],
  [trp_borcha,"borcha_prisoner_set_free", [], "Thank you boss, you won't regret this.", "close_window",
   [(remove_member_from_party,"trp_borcha"),(troop_join,"trp_borcha"),(assign,"$borcha_freed",1)]],
  [trp_borcha|plyr,"borcha_prisoner_34", [], "[Forget it]", "borcha_prisoner_34b",[]],
  [trp_borcha|plyr,"borcha_prisoner_34b", [], "You almost made me believe your foolish lies. Now shut up and keep walking.", "close_window",[]],

  [trp_borcha,"prisoner_chat", [], "Yes boss.", "borcha_prisoner_talk",[]],
  [trp_borcha|plyr,"borcha_prisoner_talk", [[neq,"$borcha_asked_for_freedom"],[eq,"$borcha_freed"]],
   "Are you really that good at scouting?", "borcha_prisoner_31",[]],


  [trp_borcha|plyr,"borcha_prisoner_talk", [], "It's nothing. Keep walking.", "close_window",[]],

  [trp_ymira,"start", [[eq,"$ymira_introduced",0]], "Please {sir/madam}, you must help me! They are going to kill me if you don't!", "ymira_introduce_1",
   [[assign,"$ymira_introduced",1]]],
  [trp_ymira|plyr,"ymira_introduce_1", [], "Easy now. Noone can harm you as long as I am here.", "ymira_introduce_2a",[]],
  [trp_ymira,"ymira_introduce_2a", [], "Oh, is that true? God bless you {sir/madam}...", "ymira_introduce_2a_1",[]],
  [trp_ymira|plyr,"ymira_introduce_2a_1", [], "Now calm down and tell me who's after you.", "ymira_introduce_2a_2",[]],
  [trp_ymira,"ymira_introduce_2a_2", [], "I don't know... bad men... please let me come with you...", "ymira_introduce_2a_3",[]],
  [trp_ymira|plyr,"ymira_introduce_2a_3", [], "What? Do you want to join my party?", "ymira_introduce_8",[]],
  [trp_ymira,"ymira_introduce_8", [], "Please, let me come with you {sir/madam}.\
 I will look after your horses, I will wash your clothes... I work very had... and I eat very little...\
 Please, You must let me come with you...", "ymira_ask_join",[]],
  [trp_ymira|plyr,"ymira_ask_join", [], "All right...", "ymira_ask_join_1",[]],
  [trp_ymira,"ymira_ask_join_1", [], "Oh, thank you...", "ymira_ask_join_2",[]],
  [trp_ymira|plyr,"ymira_ask_join_2", [[hero_can_join]], "What is your name?", "ymira_ask_join_3",[]],
  [trp_ymira,"ymira_ask_join_3", [], "Ymira.", "ymira_ask_join_4",[]],
  [trp_ymira|plyr,"ymira_ask_join_4", [], "Well Ymira. You can come with me for now.\
 I will decide what to do with you later.", "ymira_ask_join_5",[]],
#  [ymira,"ymira_ask_join_5", [], "Oh, God bless you. Thank you, thank you very much.\
# I will work very hard for you. I promise.", "close_window",
#   [[assign,"ymira_joined_party",1],
#    [remove_party,p_frightened_girl],
#    [troop_join,ymira,1]]],

  [trp_ymira|plyr,"ymira_ask_join_2", [[neg|hero_can_join]], "But unfortunately.\
 My party is full at the moment. I can't take anyone else with me. Wait here, I will think of something.", "ymira_join_decline",[]],

#  [trp_ymira|plyr,"ymira_ask_join", [], "No way. This is no life for a girl like you.", "ymira_join_decline",[]],
#  [trp_ymira,"ymira_join_decline", [], "Oh no, please don't leave me here...", "close_window",
#   [[party_set_ai_behavior,p_frightened_girl,ai_bhvr_hold]]],


  [trp_ymira|plyr,"ymira_introduce_1", [], "Go find some soldiers to protect you. I don't have time for this.", "ymira_introduce_2b",[]],
  [trp_ymira,"ymira_introduce_2b", [], "But it is the soldiers that are going to kill me.", "ymira_introduce_2b_1",[]],
  [trp_ymira|plyr,"ymira_introduce_2b_1", [], "I wouldn't want to cross with any soldiers. Get lost now.", "ymira_join_decline",[]],
  [trp_ymira|plyr,"ymira_introduce_2b_1", [], "You are running from soldiers? In that case...", "ymira_introduce_8",[]],

  [trp_ymira,"start", [[eq,"$ymira_joined_party",0]], "Please... please let me come with you.", "ymira_ask_join",
   []],

  [trp_ymira,"start", [], "Do you want me to rejoin you?", "member_wilderness_talk",[]],
  [trp_ymira,"start", [[neg|main_party_has_troop,"trp_ymira"]], "Do you want me to rejoin you?", "member_inn_talk",[]],
  [trp_ymira,"member_separate_inn", [], "I don't know what you will do without me, but you are the boss. I'll wait for you at the Four Ways inn.", "close_window",
   [[store_conversation_troop,reg(0)],[remove_member_from_party,reg(0)],[add_troop_to_site, reg(0), "scn_four_ways_inn", ymira_inn_entry]]],






# Random quests
###################################################### 

  [anyone ,"start", [(store_conversation_troop, reg(5)),(ge,reg(5),governers_begin),(lt,reg(5),governers_end)],
   "Well {playername}...", "governer_start",
   [
       (store_encountered_party, reg(5)),
       (store_faction_of_party,"$governer_faction",reg(5)),
       (try_begin,0),
       (eq,"$governer_faction","fac_swadians"),
       (assign,"$governer_enemy_faction","fac_vaegirs"),
       (assign,"$governer_relation","$player_relation_to_swadians"),
       (else_try,0),
       (assign,"$governer_enemy_faction","fac_swadians"),
       (assign,"$governer_relation","$player_relation_to_vaegirs"),
       (end_try,0),
    ]],

  [anyone,"governer_start", [[eq,"$governer_relation",rel_neutral],[store_partner_faction,reg(1)],[eq,reg(1),"fac_swadians"]],
   "We are waging war against the Vaegirs to bring justice and order to these lands.\
 Why don't you join us in our cause? You seem to be an able fighter.\
 We need {men/people} like you who will take part in our glory and share the spoils of our victory.", "governer_talk",[]],
  [anyone,"governer_start", [[eq,"$governer_relation",rel_neutral]],
   "Did you consider to join the Vaegir army?\
 A warrior needs to fight for a righteous cause,\
 otherwise he will be no better than a common thug.\
 Join the Vaegir army and help us in our sacred war against the wretched Swadians.", "governer_talk",[]],

  [anyone,"governer_start", [[eq,"$governer_relation",rel_ally],[store_partner_faction,reg(1)],[eq,reg(1),"fac_swadians"]],
   "Yes?", "governer_talk",[
     [assign,"$nobleman_party_template","pt_vaegir_nobleman"],
     ]],
  [anyone,"governer_start", [[eq,"$governer_relation",rel_ally],[store_partner_faction,reg(1)],[eq,reg(1),"fac_vaegirs"]],
   "Yes?", "governer_talk",[
     [assign,"$nobleman_party_template","pt_swadian_nobleman"],
     ]],

  
  [anyone|plyr ,"governer_talk", [[eq,"$governer_relation",rel_neutral],[neq,"$faction_locked",1],[store_partner_faction,reg(1)],[eq,reg(1),"fac_swadians"]],
   "I want to enter Swadian service and fight your enemies.", "ask_enter_swadian_service",[]],
  [anyone|plyr ,"governer_talk", [[eq,"$governer_relation",rel_neutral],[neq,"$faction_locked",1],[store_partner_faction,reg(1)],[eq,reg(1),"fac_vaegirs"]],
   "I want to join the Vaegir cause, my lord.", "ask_enter_vaegir_service",[]],
#  [anyone|plyr ,"governer_talk_neutral", [], "I must leave now. Good-bye.", "close_window",[]],
  [anyone,"ask_enter_swadian_service", [], "A wise decision {playername}. Our army is destined to win this war.\
 Now swear before God that you drop all other bounds\
 and from now on you will serve only King Harlaus and his Swadian army.", "swear_swadian",[]],
  [anyone|plyr ,"swear_swadian", [], "I swear. From now on your enemies are my enemies.", "swear_swadian_accepted",[]],
  [anyone|plyr ,"swear_swadian", [], "I need some time to think about this.", "swear_denied",[]],
  [anyone ,"swear_swadian_accepted", [], "Then I welcome you among our ranks.\
 {playername}, from now on, you are a soldier of the Swadian cause.", "swear_accepted_2",
   [
    (assign,"$wages",0),
    (assign,"$weekly_wage",3),
    (assign,"$faction_rank",0),
    (assign,"$quest_points",0),
    (store_relation,reg(0),"fac_swadians","fac_player_faction"),
    (val_max,reg(0), 3),
    (set_relation,"fac_swadians","fac_player_faction", reg(0)),
    (assign,"$player_relation_to_swadians",rel_ally),
    (store_relation,reg(0),"fac_vaegirs","fac_player_faction"),
    (val_min,reg(0),-3),
    (set_relation,"fac_vaegirs","fac_player_faction", reg(0)),
    (assign,"$player_relation_to_vaegirs",rel_enemy),
   ]],
  [anyone ,"swear_accepted_2", [[store_partner_faction,reg(1)],[eq,reg(1),"fac_swadians"]],
 "The battle with the Vaegirs is persistant and brutal. Find them wherever they hide and crush them beneath your Swadian heel. By Swadian law, you have full right of conquest, and will share in our inevitable victory.\
Besides taking what you can from their thieving fingers, myself and the other Swadian lords and generals may have specific tasks for you, depending on how the war tilts. These missions will be vital to the Swadian war effort, so carry them out with devotion and loyalty, and the rank and privilege of the Swadian empire will open its doors to you.\
 May victory grace our armies, and the blood of Vaegirs stain the field.", "governer_pretalk_ally",[]],
  [anyone ,"swear_accepted_2", [],
 "I charge you with attacking Swadian troops wherever you come across them.\
 Moreover, I and other Vaegir lords can have missions for you from time to time.\
 Carry out these missions with righteous fury, stay loyal and be brave, and you will rise in the service of the Vaegirs. Our strength and resolve is beyond compare, and victory will soon be ours.\
 May God grant victory to our cause.", "governer_pretalk_ally",[]],
  [anyone,"ask_enter_vaegir_service", [], "Good. Now swear before God that you drop all other bounds\
 and from now on you will serve only King Yaroglekand his Vaegir army.", "swear_vaegir",[]],
  [anyone|plyr ,"swear_vaegir", [], "I swear. From now on your enemies are my enemies.", "swear_vaegir_accepted",[]],
  [anyone|plyr ,"swear_vaegir", [], "I need some time to think about this.", "swear_denied",[]],
  [anyone ,"swear_vaegir_accepted", [], "Then I welcome you among our ranks.\
 From now on, you are a soldier of the Vaegir army. May God help us in our war", "swear_accepted_2",
   [
    (assign,"$wages",0),
    (assign,"$weekly_wage",3),
    (assign,"$faction_rank",0),
    (assign,"$quest_points",0),
    (store_relation,reg(0),"fac_vaegirs","fac_player_faction"),
    (val_max,reg(0), 3),
    (set_relation,"fac_vaegirs","fac_player_faction", reg(0)),
    (assign,"$player_relation_to_vaegirs",rel_ally),
    (store_relation,reg(0),"fac_swadians","fac_player_faction"),
    (val_min,reg(0),-3),
    (set_relation,"fac_swadians","fac_player_faction", reg(0)),
    (assign,"$player_relation_to_swadians",rel_enemy),
   ]],

  [anyone ,"swear_denied", [], "You aren't fooling me are you? Now go make up your mind and\
 stop wasting my time.", "close_window",[]],

  [anyone,"governer_start", [[eq,"$governer_relation",rel_enemy]],
   "You are an enemy to us {playername}. However you have come here under a truce and your life is safe for the moment.\
   But do not expect hospitality from us.", "governer_talk",[]],
  [anyone|plyr ,"governer_talk", [[eq,"$governer_relation",rel_enemy],[store_partner_faction,reg(1)],[eq,reg(1),"fac_swadians"]],
   "My lord, I ask for your forgiveness for my past deeds.", "governer_correct_relations",[]],
  [anyone|plyr ,"governer_talk", [[eq,"$governer_relation",rel_enemy],[store_partner_faction,reg(1)],[eq,reg(1),"fac_vaegirs"]],
   "My lord, I ask for your forgiveness for my past deeds.", "governer_correct_relations",[]],
#  [anyone|plyr ,"governer_talk_enemy", [], "I must leave now. Good-bye.", "close_window",[]],
  [anyone ,"governer_correct_relations", [[store_partner_faction,reg(1)],[eq,reg(1),"fac_swadians"]], "It is wise of you to say that.\
 We Swadians are destined to win this war. But you are lucky. I believe you are sincere in your remorse and thus I decided to act in your favor.\
 I can arrange for the Swadian crown pardon your acts if you can prove your trustworthiness by... compensating me for my efforts... So,\
 shall we say... {reg1} denars?", "governer_correct_relations_3",
   [[store_relation,reg(0),"fac_swadians","fac_player_faction"],
    [assign,reg(1),1],
    [val_sub,reg(1),reg(0)],
    [val_max,reg(1),1],
    [val_mul,reg(1),5],
    [assign,"$bribe_money",reg(1)],
   ]],
  [anyone ,"governer_correct_relations", [[store_partner_faction,reg(1)],[eq,reg(1),"fac_vaegirs"]], "It is wise of you to say that.\
 The Vaegirs are destined to win this war. We are ready to forget your crimes against us,\
 but of course you will have to pay for the damages you have caused.\
 Bring me {reg1} denars. I will act in your favor, and there will be no more quarrel between us.", "governer_correct_relations_3",
   [[store_relation,reg(0),"fac_vaegirs","fac_player_faction"],
    [assign,reg(1),1],
    [val_sub,reg(1),reg(0)],
    [val_max,reg(1),1],
    [val_mul,reg(1),10],
    [assign,"$bribe_money",reg(1)],
    ]],
  [anyone|plyr ,"governer_correct_relations_3", [[assign,reg(1),"$bribe_money"],[store_troop_gold,reg(2),"trp_player"],[ge,reg(2),reg(1)]],
   "Of course milord. Here, please take these {reg1} denars.", "governer_correct_relations_4",
   [[assign,reg(1),"$bribe_money"],[troop_remove_gold, "trp_player",reg(1)]]],
  [anyone,"governer_correct_relations_4", [[store_partner_faction,reg(1)],[eq,reg(1),"fac_swadians"],[eq,"$player_relation_to_vaegirs",rel_ally]],
 "Good. You have made a wise decision, halting your inevitable defeat alongside those cowardly Vaegirs.", "governer_correct_relations_5",
   [[assign,"$player_relation_to_vaegirs",rel_neutral],
    [cancel_quest,"qst_supply_equipment"],
    [cancel_quest,"qst_supply_armor"],
    [cancel_quest,"qst_supply_horses"],
    [cancel_quest,"qst_deliver_message"],
    [cancel_quest,"qst_capture_prisoners"],
    [cancel_quest,"qst_raise_troops"],
    ]],
  [anyone,"governer_correct_relations_4", [[store_partner_faction,reg(1)],[eq,reg(1),"fac_vaegirs"],[eq,"$player_relation_to_swadians",rel_ally]],
 "Good. You'll not need to waste yourself serving those wretched Swadians any longer.", "governer_correct_relations_5",
   [[assign,"$player_relation_to_swadians",rel_neutral],
    [cancel_quest,"qst_supply_equipment"],
    [cancel_quest,"qst_supply_armor"],
    [cancel_quest,"qst_supply_horses"],
    [cancel_quest,"qst_deliver_message"],
    [cancel_quest,"qst_capture_prisoners"],
    [cancel_quest,"qst_raise_troops"],
    ]],
  [anyone,"governer_correct_relations_4", [],"Excellent {playername}.", "governer_correct_relations_5",[]],

  [anyone,"governer_correct_relations_5", [(store_partner_faction,reg(1)),(eq,reg(1),"fac_swadians")],
 "I will send word to our troops now and write a few letters.\
 It will take some time to work everything out, but you can consider the hostility between us gone.\
 Swadian army will hunt you no more, {playername}.", "close_window",
   [(assign,"$player_relation_to_swadians",rel_neutral),
    (set_relation,"fac_swadians", "fac_player_faction",0)]],
  [anyone,"governer_correct_relations_5", [(store_partner_faction,reg(1)),(eq,reg(1),"fac_vaegirs")], "I will take the necessary actions now.\
 It will take some time to work everything out, but you can consider the hostility between us gone.\
 Vaegir army will hunt you no more, {playername}.", "close_window",
   [(assign,"$player_relation_to_vaegirs",rel_neutral),
    (set_relation,"fac_vaegirs", "fac_player_faction",0)]],

  [anyone|plyr ,"governer_correct_relations_3", [], "I need some time to collect that much money.", "governer_correct_relations_4b",[]],
  [anyone,"governer_correct_relations_4b", [], "Whatever. You heard my terms. You can get a pardon if you are willing to pay for it.", "close_window",[]],

#Promotions
  [anyone,"governer_pretalk_ally", [[ge,"$quest_points",2],[lt,"$faction_rank",1]],
   "And I am happy to inform you that you have earned a promotion. From now on, you rank as a regular of the army. Congratulations. You will also be receiving an increase of your wages, to {reg0} denars per week.", "governer_pretalk_ally",
   [[assign,"$weekly_wage",6],[assign,reg(0),"$weekly_wage"],[assign,"$faction_rank",1]]],
  [anyone,"governer_pretalk_ally", [[ge,"$quest_points",6],[lt,"$faction_rank",2]],
   "Your deeds do not go unnoticed, {playername}. From now on, you rank as a veteran of the army, with a wage of {reg0} denars. Congratulations.", "governer_pretalk_ally",
   [[assign,"$weekly_wage",9],[assign,reg(0),"$weekly_wage"],[assign,"$faction_rank",2]]],
  [anyone,"governer_pretalk_ally", [[ge,"$quest_points",15],[lt,"$faction_rank",3]],
   "My scouts have brought tales of your cunning and valour, {playername}. From now on you rank as a sergeant of the army. And your wages will amount to {reg0} denars per week. You've earned it.", "governer_pretalk_ally",
   [[assign,"$weekly_wage",13],[assign,reg(0),"$weekly_wage"],[assign,"$faction_rank",3]]],
  [anyone,"governer_pretalk_ally", [[ge,"$quest_points",27],[lt,"$faction_rank",4]],
   "The men speak highly of you, {playername}. From now on you rank as a sergeant-at-arms of the army, and your wage will increase to {reg0} denars per week. You are an inspiration to the troops, and I thank you.", "governer_pretalk_ally",
   [[assign,"$weekly_wage",17],[assign,reg(0),"$weekly_wage"],[assign,"$faction_rank",4]]],
  [anyone,"governer_pretalk_ally", [[ge,"$quest_points",40],[lt,"$faction_rank",5]],
   "The lords have spoken of you, {playername}, and we have decided to let you enter the most elite service of our army. From now on you rank as a squire, a stepping stone into the realm of our greatest champions. Your wage will reflect this, at {reg0} denars per week. Who knows, perhaps one day your name will be engraved in history like those before you.", "governer_pretalk_ally",
   [[assign,"$weekly_wage",22],[assign,reg(0),"$weekly_wage"],[assign,"$faction_rank",5]]],
  [anyone,"governer_pretalk_ally", [[ge,"$quest_points",60],[lt,"$faction_rank",6]],
   "You have completed your service as a squire, {playername}, and proven your valor in battle many times. Now, bow before me to receive this well deserved honor you have earned. {playername}! In recognition of your services to our kingdom, I dub thee knight. Carry your title with honour and humility. Now rise {sir/lady} {playername}, and go give our enemies hell!", 
	 "governer_pretalk_ally",
   [[assign,"$weekly_wage",28],[assign,reg(0),"$weekly_wage"],[assign,"$faction_rank",6]]],
  [anyone,"governer_pretalk_ally", [[ge,"$quest_points",80],[lt,"$faction_rank",7]],
   "You impress even our veteran knights, {playername}. Your deeds speak of our cause, and your words are taken to heart by the troops. Please accept the position of a knight-at-arms, with a weekly wage of {reg0} denars.", "governer_pretalk_ally",
   [[assign,"$weekly_wage",35],[assign,reg(0),"$weekly_wage"],[assign,"$faction_rank",7]]],
  [anyone,"governer_pretalk_ally", [[ge,"$quest_points",110],[lt,"$faction_rank",8]],
   "Even our knights are humbled by your victories, {playername}. They shout your name in song and chant as they march, and the bards are competing to see who can concoct the most clever rhyme. You are promoted to sergeant-knight, with a wage of {reg0} denars per week.", "governer_pretalk_ally",
   [[assign,"$weekly_wage",45],[assign,reg(0),"$weekly_wage"],[assign,"$faction_rank",8]]],
  [anyone,"governer_pretalk_ally", [[ge,"$quest_points",140],[lt,"$faction_rank",9]],
   "You are on a path that few can achieve, and even the lords nod and smile when they hear your name. True greatness is rarely reached, but you have shown that one can rise from nothing and wretch victory from the enemy again and again. You are now a sergeant-knight-at-arms, with your wage increased to {reg0}. Do us proud, {playername}, we will never grow tired of your tales of victory.", "governer_pretalk_ally",
   [[assign,"$weekly_wage",60],[assign,reg(0),"$weekly_wage"],[assign,"$faction_rank",9]]],
  [anyone,"governer_pretalk_ally", [[ge,"$quest_points",200],[lt,"$faction_rank",10]],
   "I must admit I am a little awed at your presence. You are a becoming a legend, {playername}. The enemy wets themselves at the mere mention of your name, and accepts their fate when you enter the battlefield. Please accept the title of master-knight, with wages of {reg0}. Even breath you draw is one closer to victory. We're depending on you, {playername}.", "governer_pretalk_ally",
   [[assign,"$weekly_wage",85],[assign,reg(0),"$weekly_wage"],[assign,"$faction_rank",10]]],
  [anyone,"governer_pretalk_ally", [[ge,"$quest_points",300],[lt,"$faction_rank",11]],
   "Ah, {playername} the Great. Or is it {playername} the Invincible? Which title do you prefer? You can choose from any the bards have thought up, I suppose. That is a right few can claim. You are our greatest champion, {playername}. When the history of this war is written, a hundred years from now, it is your name that they will remember above all else.\
You are the first grandmaster-knight. The meager {reg0} denars per week we offer hardly seems fitting, I know, but please accept this humble offering. I don't often use the word hero, but I permit myself to do so now. You are a hero to all that fly our banners and a living testament to the victory we march towards. Go forth, hero {playername}, and take victory for our people.", "governer_pretalk_ally",
   [[assign,"$weekly_wage",120],[assign,reg(0),"$weekly_wage"],[assign,"$faction_rank",11]]],
  
  [anyone,"governer_pretalk_ally", [],
   "Well I guess that will be all for now {playername}.", "close_window",[]],
#  [anyone|plyr,"governer_pretalk_ally", [],
#   "Thank you milord.", "close_window",[]],
  [anyone,"governer_pretalk_ally", [[store_partner_faction,reg(1)],[eq,reg(1),"fac_swadians"]],
   "Anything else?", "governer_talk",[]],
  [anyone,"governer_pretalk_ally", [[store_partner_faction,reg(1)],[eq,reg(1),"fac_vaegirs"]],
   "Anything else?", "governer_talk",[]],
  
  [anyone|plyr,"governer_talk",[[check_quest_active,"qst_deliver_message",1],
                                     [store_encountered_party,reg(5)],
                                     [eq,reg(5),"$message_quest_town"],
                                     [str_store_troop_name,1,"$message_quest_giver"],
                                     [str_store_party_name,2,"$message_quest_giver_town"]],
   "I have brought you a message from {s1} of {s2} milord.", "governer_message_delivered",
   [
     [troop_add_gold, "trp_player",10],
     [add_xp_as_reward,100],
     [complete_quest,"qst_deliver_message"],
     ]],
  [anyone,"governer_message_delivered", [], "Hmm let me see that. You can leave now. And here take this money.", "close_window",[]],

  [anyone|plyr,"governer_talk", [[store_partner_quest,reg(2)],[ge,reg(2),0]], "About the mission you gave me sir...", "governer_active_mission_1",[]],
  [anyone,"governer_active_mission_1", [], "Yes, have you made any progress on it?", "governer_active_mission_2",[]],
# DEBUG  
#  [anyone|plyr,"governer_active_mission_2", [],
#   "I have completed the mission.", "governer_mission_complete",[[val_add,"$quest_points",1],]],
  [anyone|plyr,"governer_active_mission_2",
   [[store_partner_quest,reg(2)],[eq,reg(2),"qst_supply_horses"],
    [store_item_kind_count,reg(8),"$horse_quest_item_kind"],
    [ge,reg(8),"$horse_quest_number"],[assign,reg(7),"$horse_quest_number"],[str_store_item_name,1,"$horse_quest_item_kind"]],
   "I have brought {reg7} {s1} as you ordered.", "governer_mission_complete",
   [  [troop_remove_items, 0,"$horse_quest_item_kind","$horse_quest_number"],
#      [store_item_value,reg(10),"horse_quest_item_kind"],
#      [val_mul,reg(10),"horse_quest_number"],
      [assign,reg(10),reg(0)],
      [val_mul,reg(10),10],
      [val_div,reg(10),4],
      [store_add, reg(10),reg(10),10],
      [troop_add_gold, "trp_player",reg(10)],
      [assign,reg(20),2],
      [val_add,reg(20),"$horse_quest_item_kind"],
      [val_sub,reg(20),"itm_sumpter_horse"],
      [val_mul,reg(20),"$horse_quest_number"],
      [val_mul,reg(20),4],
      [add_xp_as_reward,reg(20)],
      [val_add,"$quest_points",2],
      ]],
  [anyone|plyr,"governer_active_mission_2",
   [[store_partner_quest,reg(2)],[eq,reg(2),"qst_supply_equipment"],
    [store_item_kind_count,reg(8),"$equipment_quest_item_kind"],
    [ge,reg(8),"$equipment_quest_number"],[assign,reg(7),"$equipment_quest_number"],[str_store_item_name,1,"$equipment_quest_item_kind"]],
   "I have brought the equipment you asked for, my lord.", "governer_mission_complete",
   [  [troop_remove_items, 0,"$equipment_quest_item_kind","$equipment_quest_number"],
#      [store_item_value,reg(10),"equipment_quest_item_kind"],
#      [val_mul,reg(10),2],
#      [val_mul,reg(10),"equipment_quest_number"],
      [assign,reg(10),reg(0)],
      [val_mul,reg(10),9],
      [val_div,reg(10),4],
      [val_add,reg(10),10],
      [troop_add_gold, "trp_player",reg(10)],
      [assign,reg(20),7],
      [val_mul,reg(20),"$equipment_quest_number"],
      [val_add,reg(20),30],
      [add_xp_as_reward,reg(20)],
      [val_add,"$quest_points",2],
      ]],
  [anyone|plyr,"governer_active_mission_2",
   [[store_partner_quest,reg(2)],[eq,reg(2),"qst_supply_armor"],
    [store_item_kind_count,reg(8),"$armor_quest_item_kind"],
    [ge,reg(8),"$armor_quest_number"],[assign,reg(7),"$armor_quest_number"],[str_store_item_name,1,"$armor_quest_item_kind"]],
   "I have brought the armors you asked for, my lord.", "governer_mission_complete",
   [  [troop_remove_items, 0,"$armor_quest_item_kind","$armor_quest_number"],
#      [store_item_value,reg(10),"armor_quest_item_kind"],
#      [val_mul,reg(10),3],
#      [val_mul,reg(10),"armor_quest_number"],
      [assign,reg(10),reg(0)],
      [val_mul,reg(10),9],
      [val_div,reg(10),4],
      [val_add,reg(10),10],
      [troop_add_gold, "trp_player",reg(10)],
      [assign,reg(20),7],
      [val_mul,reg(20),"$armor_quest_number"],
      [val_add,reg(20),30],
      [add_xp_as_reward,reg(20)],
      [val_add,"$quest_points",2],
      ]],
  [anyone|plyr,"governer_active_mission_2",
   [[store_partner_quest,reg(2)],[eq,reg(2),"qst_capture_prisoners"],[store_troop_count_prisoners,reg(8),"$capture_prisoners_quest_troop"],
    [ge,reg(8),"$capture_prisoners_quest_number"],[assign,reg(1),"$capture_prisoners_quest_number"],[str_store_troop_name_plural,1,"$capture_prisoners_quest_troop"]],
   "I have brought you {reg1} {s1} as prisoners, my lord.", "governer_mission_complete",[
      [remove_troops_from_prisoners,"$capture_prisoners_quest_troop","$capture_prisoners_quest_number"],
      [store_troop_value,reg(10),"$capture_prisoners_quest_troop"],
      [val_mul,reg(10),5],
      [val_mul,reg(10),"$capture_prisoners_quest_number"],
      [val_add,reg(10),10],
      [troop_add_gold, "trp_player",reg(10)],
      [assign,reg(20),7],
      [val_mul,reg(20),"$capture_prisoners_quest_number"],
      [val_add,reg(20),30],
      [add_xp_as_reward,reg(20)],
      [val_add,"$quest_points",2],
     ]],
  [anyone|plyr,"governer_active_mission_2",
   [[store_partner_quest,reg(2)],[eq,reg(2),"qst_raise_troops"],[store_troop_count_companions,reg(8),"$raise_troops_quest_troop"],
    [ge,reg(8),"$raise_troops_quest_number"]],
   "I have raised the troops you asked for, my lord.", "governer_mission_complete",[
      [remove_troops_from_companions,"$raise_troops_quest_troop","$raise_troops_quest_number"],
      [store_troop_value,reg(10),"$raise_troops_quest_troop"],
      [val_mul,reg(10),"$raise_troops_quest_number"],
      [val_mul,reg(10),5],
      [val_div,reg(10),2],
      [val_add,reg(10),4],
      [troop_add_gold, "trp_player",reg(10)],
      [assign,reg(20),30],
      [val_mul,reg(20),"$raise_troops_quest_number"],
      [val_add,reg(20),40],
      [add_xp_as_reward,reg(20)],
      [val_add,"$quest_points",2],
     ]],

  [anyone|plyr,"governer_active_mission_2",
   [[store_partner_quest,reg(2)],[eq,reg(2),"qst_capture_nobleman"],[store_troop_count_prisoners,reg(3),"trp_nobleman"],[ge,reg(3),1]],
   "I have captured the nobleman sir.", "governer_mission_complete",[
      [remove_troops_from_prisoners,"trp_nobleman",1],
      [troop_add_gold, "trp_player",1000],
      [add_xp_as_reward,3500],
      [val_add,"$quest_points",6],
      [assign,"$nobleman_quest_nobleman_active",0],
     ]],
  
  [anyone|plyr,"governer_active_mission_2",
   [[store_partner_quest,reg(2)],[eq,reg(2),"qst_capture_nobleman"],[eq,"$nobleman_quest_failed",1]],
   "I was unable to capture that nobleman sir.", "governer_mission_failed",[
     ]],
  
  [anyone|plyr,"governer_active_mission_2",
   [[store_partner_quest,reg(2)],[eq,reg(2),"qst_hunt_down_raiders"],[eq,"$raider_quest_succeeded",1]],
   "I have given those raiders the punishment they deserved.", "governer_mission_complete",[
      [troop_add_gold, "trp_player",500],
      [add_xp_as_reward,4500],
      [val_add,"$quest_points",5],
     ]],
  [anyone|plyr,"governer_active_mission_2",
   [[store_partner_quest,reg(2)],[eq,reg(2),"qst_hunt_down_raiders"],[eq,"$raider_quest_failed",1]],
   "I was unable to catch those raiders sir.", "governer_mission_failed",[
     ]],

  [anyone|plyr,"governer_active_mission_2", [], "I am still working on it sir.", "governer_active_mission_3",[]],
  [anyone,"governer_active_mission_3", [], "Good. Keep working. We need to do our best to win this war.", "close_window",[]],

  [anyone,"governer_mission_complete", [], "Excellent {playername}. You are really reliable. I will not forget your service at this.", "governer_pretalk_ally",
   [[store_partner_quest,reg(2)],[complete_quest,reg(2)],[val_add,"$num_quests_fulfilled",1]]],
  [anyone,"governer_mission_failed", [], "Well. It was a long call anyway. Let us hope you will be luckier next time.", "governer_pretalk_ally",
   [[store_partner_quest,reg(2)],[complete_quest,reg(2)],[val_add,"$num_quests_failed",1]]],

  [anyone|plyr,"governer_talk", [[store_partner_quest,reg(2)],[lt,reg(2),0],[eq,"$governer_relation",rel_ally]], "Do you have any mission for me sir?", "governer_talk_quest_asked",[]],
#  [anyone,"governer_talk_quest_asked", [[store_partner_quest_status,reg(2)],[eq,reg(2),0]], "I don't have any mission for you at this moment {playername}. But ask me again in a few days. I might have something for you then.", "governer_pre_talk",[]],
  [anyone,"governer_talk_quest_asked", [[store_partner_quest,reg(2)],[ge,reg(2),0]], "Well {playername}. You still have not finished the mission I gave you. You should be working on that now.", "governer_pre_talk",[]],
  [anyone,"governer_talk_quest_asked", [[store_partner_faction,reg(1)],[eq,reg(1),"fac_swadians"],
                                        [store_random_quest_in_range,reg(0),governer_quests_begin,governer_quests_end],
                                        [neq,reg(0),-1],[assign,"$random_quest_no",reg(0)]
                                        ], "A mission? As a matter of fact I just need you to carry out a mission for me.", "governer_tell_mission",
   [[assign,"$enemy_base_troop","trp_vaegir_peasant"],
    [assign,"$ally_base_troop","trp_swadian_peasant"],
    [assign,"$enemy_raider_party","pt_vaegir_raiders"],
    ]],
  [anyone,"governer_talk_quest_asked", [[store_partner_faction,reg(1)],[eq,reg(1),"fac_vaegirs"],
                                        [store_random_quest_in_range,reg(0),governer_quests_begin,governer_quests_end],
                                        [neq,reg(0),-1],[assign,"$random_quest_no",reg(0)],
                                        ], "A mission? As a matter of fact I just need you to carry out a mission for me.", "governer_tell_mission",
   [[assign,"$enemy_base_troop","trp_swadian_peasant"],
    [assign,"$ally_base_troop","trp_vaegir_peasant"],
    [assign,"$enemy_raider_party","pt_swadian_raiders"],
    ]],
  [anyone,"governer_talk_quest_asked", [], "A mission? No {playername}. I do not need your services at this time.", "governer_pretalk_ally",[]],

  [anyone,"governer_tell_mission", [(eq,"$random_quest_no","qst_deliver_message"),
                                    (assign, "$pin_faction", "$governer_faction"),
                                    (call_script,"script_select_faction_town"),
                                    (assign,"$message_quest_town","$pout_town"),
                                    (store_encountered_party,"$message_quest_giver_town"),
                                    (neq,"$message_quest_town","$message_quest_giver_town"),
                                    ],
   "I need you to deliver a message to the lord of {s3}. Get on the road as soon as possible.", "governer_mission_told",
   [
     [store_conversation_troop,"$message_quest_giver"],
     [str_store_troop_name,1,"$message_quest_giver"],
     [str_store_party_name,2,"$message_quest_giver_town"],
     [str_store_party_name,3,"$message_quest_town"],
     [setup_quest_text,"$random_quest_no"],
   ]],
  [anyone,"governer_tell_mission", [(eq,"$random_quest_no","qst_supply_horses")], "In the last battle we lost too many good horses and my stables are now almost empty.\
 I need you to bring me {reg1} {s3}s. Talk to horse merchants, visit farms, heck steal them if necessary.\
 Just get me those horses.", "governer_mission_horses_1", [
    [store_random,reg(1),5],
    [val_add,reg(1),4],
    [store_character_level,reg(7)],
    [val_div,reg(7),5],
    [val_add,reg(1),reg(7)],
    [assign,"$horse_quest_number",reg(1)],
    [store_character_level,reg(6)],
    [val_div,reg(6),4],
    [val_min,reg(6),7],
    [store_random,reg(3),reg(6)],
    [val_add,reg(3),"itm_sumpter_horse"],
#    [store_random_horse,reg(3)],
    [assign,"$horse_quest_item_kind",reg(3)],
    [str_store_item_name,3,reg(3)],
    [store_conversation_troop,reg(25)],[str_store_troop_name,1,reg(25)],
    [store_encountered_party,reg(26)],[str_store_party_name,2,reg(26)],
    [setup_quest_text,"$random_quest_no"],
   ]],
  [anyone|plyr,"governer_mission_horses_1", [], "Sir, can I get some money for the expenses?", "governer_mission_horses_2",[]],
  [anyone,"governer_mission_horses_2", [], "Sure, sure. Bring the horses and I will pay for your expenses and of course something extra for you too.", "governer_mission_told",[]],
  [anyone,"governer_tell_mission", [(eq,"$random_quest_no","qst_supply_equipment")],
 "I am raising a new company of troops {playername}.\
 Soon they will be ready for battle except that we can't fully equip them from my armory.\
 I need to purchase some of the equipment from outside.\
 Now, I want you to bring me {reg1} {s3}.\
 I will pay handsomely for your effort as soon as you have brought them.", "governer_mission_told", [
    [store_random,reg(1),4],[val_add,reg(1),3],
    [assign,"$equipment_quest_number",reg(1)],
    [store_random_equipment,reg(3)],
    [assign,"$equipment_quest_item_kind",reg(3)],
    [str_store_item_name,3,reg(3)],
    [store_conversation_troop,reg(25)],[str_store_troop_name,1,reg(25)],
    [store_encountered_party,reg(26)],[str_store_party_name,2,reg(26)],
    [setup_quest_text,"$random_quest_no"],
   ]],
  [anyone,"governer_tell_mission", [(eq,"$random_quest_no","qst_supply_armor")],
 "I am raising a new company of troops {playername}.\
 Soon they will be ready for battle except that we can't fully equip them from my armory.\
 I need to purchase some of the armor from outside.\
 Now, I want you to bring me {reg1} {s3}.\
 I will pay handsomely for your effort as soon as you have brought them.", "governer_mission_told", [
    [store_random,reg(1),4],[val_add,reg(1),3],
    [assign,"$armor_quest_number",reg(1)],
    [store_random_armor,reg(3)],
    [assign,"$armor_quest_item_kind",reg(3)],
    [str_store_item_name,3,reg(3)],
    [store_conversation_troop,reg(25)],[str_store_troop_name,1,reg(25)],
    [store_encountered_party,reg(26)],[str_store_party_name,2,reg(26)],
    [setup_quest_text,"$random_quest_no"],
   ]],
  [anyone,"governer_tell_mission", [(eq,"$random_quest_no","qst_capture_prisoners")], "We are in the dark regarding what the enemy is planning and by God, I don't like this.\
 If we capture a few prisoners, perhaps they will tell us something useful. Go now and bring me {reg1} {s3} as prisoners.", "governer_mission_told",
   [[store_random,reg(1),5],[val_add,reg(1),2],
    [assign,"$capture_prisoners_quest_number",reg(1)],
    [store_random_troop_to_capture,reg(3),"$enemy_base_troop"],
    [assign,"$capture_prisoners_quest_troop",reg(3)],
    [str_store_troop_name_plural,3,reg(3)],
    [store_conversation_troop,reg(25)],[str_store_troop_name,1,reg(25)],
    [store_encountered_party,reg(26)],[str_store_party_name,2,reg(26)],
    [setup_quest_text,"$random_quest_no"],
   ]],
  [anyone,"governer_tell_mission", [[eq,"$random_quest_no","qst_raise_troops"]], "I was inspecting the troops the other day,\
 and there are men out there who don't know which end of the sword is meant for business.\
 Fat lazy bastards. God knows if we are going to win this war, we need hardened warriors.\
 And you are going to raise those warriors for me. I want you to raise {reg1} {s3} and bring them to me.", "governer_mission_told",[
    [store_random,reg(1),5],[val_add,reg(1),2],
    [assign,"$raise_troops_quest_number",reg(1)],
    [store_random_troop_to_raise,reg(3),"$ally_base_troop"],
    [assign,"$raise_troops_quest_troop",reg(3)],
    [str_store_troop_name_plural,3,reg(3)],
    [store_conversation_troop,reg(25)],[str_store_troop_name,1,reg(25)],
    [store_encountered_party,reg(26)],[str_store_party_name,2,reg(26)],
    [setup_quest_text,"$random_quest_no"],
   ]],
  [anyone,"governer_tell_mission", [(eq,"$random_quest_no","qst_capture_nobleman"),
                                    (assign, "$pin_faction", "$governer_enemy_faction"),
                                    (call_script,"script_select_faction_town"),
                                    (assign,"$nobleman_quest_source_town","$pout_town"),
                                    (assign, "$pin_faction", "$governer_enemy_faction"),
                                    (call_script,"script_select_faction_town"),
                                    (assign,"$nobleman_quest_target_town","$pout_town"),
                                    (neq,"$nobleman_quest_source_town","$nobleman_quest_target_town"),
                                    ],
 "I have been informed that an enemy nobleman will make a journey from {s3} to {s4} in {reg1} days.\
 What is more, he will be escorted very lightly on the way.\
 Now, that nobleman's ransom must be worth a small fortune and you and I are going to claim it.\
 You must leave instantly and attack the nobleman's party on their way to {s4}.\
 Once you capture him, bring him to me. I am counting on you.", "governer_mission_told",
   [(spawn_around_party,"$nobleman_quest_source_town","$nobleman_party_template"),
    (assign, "$nobleman_quest_party_id",reg(0)),
    (party_set_ai_behavior,"$nobleman_quest_party_id",ai_bhvr_travel_to_party),
    (party_set_ai_object,"$nobleman_quest_party_id","$nobleman_quest_target_town"),
    (party_set_faction,"$nobleman_quest_party_id","$governer_enemy_faction"),
    (disable_party,"$nobleman_quest_party_id"),
    (assign,"$nobleman_quest_nobleman_enable",1),
    (assign,"$nobleman_quest_succeeded",0),
    (assign,"$nobleman_quest_failed",0),
    (assign,"$nobleman_quest_nobleman_active",0),
    (str_store_party_name,3,"$nobleman_quest_source_town"),
    (str_store_party_name,4,"$nobleman_quest_target_town"),
    (store_current_hours,reg(7)),
    (store_conversation_troop,"$nobleman_quest_giver"),
    (store_encountered_party,"$nobleman_quest_giver_town"),
    (str_store_party_name,2,"$nobleman_quest_giver_town"),
    (store_distance_to_party_from_party, reg(0),"$nobleman_quest_giver_town",reg(5)),
    (val_div,reg(0),60),
    (val_add,reg(0),1),
    (assign,reg(1),reg(0)),
    (assign,reg(1),2), #overwrite. TODO: fix this.
    (assign,reg(12),reg(0)),
    (val_mul,reg(12),24),
    (val_add,reg(7),reg(12)),
    (str_store_troop_name,1,"$nobleman_quest_giver"),
    (str_store_party_name,2,"$nobleman_quest_giver_town"),
    (setup_quest_text,"$random_quest_no"),
    ]],
  [anyone,"governer_tell_mission", [(eq,"$random_quest_no","qst_hunt_down_raiders"),
                                    (assign, "$pin_faction", "$governer_faction"),
                                    (call_script,"script_select_faction_town"),
                                    (assign,"$raider_quest_source_town","$pout_town"),
                                    (assign, "$pin_faction", "$governer_enemy_faction"),
                                    (call_script,"script_select_faction_town"),
                                    (assign,"$raider_quest_target_town","$pout_town"),
                                    (store_encountered_party,reg(11)),
                                    (neq,reg(11),"$raider_quest_source_town"),
                                    ],
 "A messenger came with important news a few hours ago.\
 A group of enemy raiders have attacked a village near {s3}.\
 They have murdered anyone who tried to resist, stolen everything they could carry and put the rest to fire.\
 Now, they must be on their way back to their base at {s4}.\
 You must catch them on the way and make them pay for their crimes.\
 God be with you.", "governer_mission_told",
   [(set_spawn_radius, 3),
    (spawn_around_party,"$raider_quest_source_town","$enemy_raider_party"),
    (assign, "$raider_quest_party_id",reg(0)),
    (party_set_ai_behavior,"$raider_quest_party_id",ai_bhvr_travel_to_party),
    (party_set_ai_object,"$raider_quest_party_id","$raider_quest_target_town"),
    (party_set_faction,"$raider_quest_party_id","$governer_enemy_faction"),
    (assign,"$raider_quest_succeeded",0),
    (assign,"$raider_quest_failed",0),
    (assign,"$raider_quest_active",1),
    (str_store_party_name,3,"$raider_quest_source_town"),
    (str_store_party_name,4,"$raider_quest_target_town"),
    (store_encountered_party,reg(11)),(str_store_party_name,2,reg(11)),
    (store_conversation_troop,reg(12)),(str_store_troop_name,1,reg(12)),
    (setup_quest_text,"$random_quest_no"),
    ]],
  [anyone,"governer_tell_mission", [], "I am afraid I wasn't able to come up with a mission for you.", "close_window",[]],

  [anyone|plyr,"governer_mission_told", [], "As you wish sir. You can count on me.", "governer_mission_accepted",[]],
  [anyone,"governer_mission_accepted", [], "Excellent. Do this {playername}. I really have high hopes for you.", "close_window",
   [[start_quest,"$random_quest_no"]]],

  [anyone|plyr,"governer_talk", [[eq,"$governer_relation",rel_ally]], "About my rank and wages...", "governer_rank_and_wages",[]],

  [anyone,"governer_rank_and_wages", [[eq,"$faction_rank", 0]], "Well... you are but a fresh recruit for our army and as such your weekly wage is {reg0} denars.", "governer_collect_wages",[[assign,reg(0),"$weekly_wage"]]],
  [anyone,"governer_rank_and_wages", [[eq,"$faction_rank", 1]], "Well... you are a regular of our army and as such your weekly wage is {reg0} denars.", "governer_collect_wages",[[assign,reg(0),"$weekly_wage"]]],
  [anyone,"governer_rank_and_wages", [[eq,"$faction_rank", 2]], "Well... you are a veteran of our army and as such your weekly wage is {reg0} denars.", "governer_collect_wages",[[assign,reg(0),"$weekly_wage"]]],
  [anyone,"governer_rank_and_wages", [[eq,"$faction_rank", 3]], "Well... you are a sergeant of our army and as such your weekly wage is {reg0} denars.", "governer_collect_wages",[[assign,reg(0),"$weekly_wage"]]],
  [anyone,"governer_rank_and_wages", [[eq,"$faction_rank", 4]], "Well... you are a sergeant-at-arms of our army and as such your weekly wage is {reg0} denars.", "governer_collect_wages",[[assign,reg(0),"$weekly_wage"]]],
  [anyone,"governer_rank_and_wages", [[eq,"$faction_rank", 5]], "Well... you are a squire in our army and as such you are entitled to  a weekly wage of {reg0} denars.", "governer_collect_wages",[[assign,reg(0),"$weekly_wage"]]],
  [anyone,"governer_rank_and_wages", [[eq,"$faction_rank", 6]], "Well... you are a knight of our army and as such you are entitled to a weekly wage of {reg0} denars.", "governer_collect_wages",[[assign,reg(0),"$weekly_wage"]]],
  [anyone,"governer_rank_and_wages", [[eq,"$faction_rank", 7]], "Well... you are a knight-at-arms of our army and as such you are entitled to a weekly wage of {reg0} denars.", "governer_collect_wages",[[assign,reg(0),"$weekly_wage"]]],
  [anyone,"governer_rank_and_wages", [[eq,"$faction_rank", 8]], "Well... you are a sergeant-knight of our army and as such you are entitled to a weekly wage of {reg0} denars.", "governer_collect_wages",[[assign,reg(0),"$weekly_wage"]]],
  [anyone,"governer_rank_and_wages", [[eq,"$faction_rank", 9]], "Well... you are a sergeant-knight-at-arms of our army and as such you are entitled to a weekly wage of {reg0} denars.", "governer_collect_wages",[[assign,reg(0),"$weekly_wage"]]],
  [anyone,"governer_rank_and_wages", [[eq,"$faction_rank",10]], "Well... you are a master-knight of our army and as such you are entitled to a weekly wage of {reg0} denars.", "governer_collect_wages",[[assign,reg(0),"$weekly_wage"]]],
  [anyone,"governer_rank_and_wages", [[eq,"$faction_rank",11]], "Well... you are the grandmaster-knight of our army and as such you are entitled to a weekly wage of {reg0} denars.", "governer_collect_wages",[[assign,reg(0),"$weekly_wage"]]],

  [anyone,"governer_collect_wages", [[eq,"$wages",0]], "You have no wages accumulated yet.", "governer_anything_else",[]],
  [anyone,"governer_collect_wages", [], "By the way, your wages have accumulated to some {reg1} denars. Well here you go.", "close_window",
   [[assign,reg(1),"$wages"],[troop_add_gold, "trp_player","$wages"],[assign,"$wages",0]]],
  [anyone,"governer_anything_else", [], "Anything else?", "governer_talk",[]],

  [anyone|plyr,"governer_talk", [[eq,"$governer_relation",rel_ally]], "May I have permission to leave now sir?", "governer_leave_ally",[]],
  [anyone,"governer_leave_ally", [], "Yes you may leave now.", "close_window",[]],
  [anyone|plyr ,"governer_talk", [[eq,"$governer_relation",rel_enemy]], "Let me be on my way now milord. Good-bye.", "close_window",[]],
  [anyone|plyr ,"governer_talk", [[eq,"$governer_relation",rel_neutral]], "Let me be on my way now milord. Good-bye.", "close_window",[]],
  

#Tavernkeepers
  [trp_zendar_tavernkeeper,"start", [], "Good day dear {sir/madam}. How can I help you?", "tavernkeeper_talk",[(assign,"$tavernkeeper_party","p_zendar_mercs")]],

  [anyone ,"start", [(store_conversation_troop,reg(1)),(ge,reg(1),tavernkeepers_begin),(lt,reg(1),tavernkeepers_end)],
   "Good day dear {sir/madam}. How can I help you?", "tavernkeeper_talk",
   [
    (store_encountered_party,reg(2)),
    (party_get_slot,"$tavernkeeper_party",reg(2),slot_town_mercs),
    ]],
  
  [anyone,"tavernkeeper_pretalk", [], "Anything else?", "tavernkeeper_talk",[]],

  [anyone|plyr,"tavernkeeper_talk", [(check_quest_active,"qst_deliver_wine"),
                                     (store_encountered_party,reg(7)),
                                     (eq,reg(7),"$deliver_wine_quest_town"),
                                     (store_item_kind_count,reg(8),"$deliver_wine_quest_item"),
                                     (ge,reg(8),"$deliver_wine_quest_number"),
                                     (assign,reg(9),"$deliver_wine_quest_number"),
                                     (str_store_item_name,2,"$deliver_wine_quest_item"),
                                     ],
   "I was told to deliver you {reg9} units of {s2}.", "tavernkeeper_deliver_wine",[]],
  [anyone,"tavernkeeper_deliver_wine", [],
 "At last! My stock was almost depleted.\
 I had paid the cost of the {s2} in advance.\
 Here, take these {reg5} denars. That should cover your pay.\
 And tell {s1} my regards.\
 I'll put in a good word for you next time I deal with him.", "tavernkeeper_pretalk",
   [[troop_remove_items, 0,"$deliver_wine_quest_item","$deliver_wine_quest_number"],
    [troop_add_gold, "trp_player","$deliver_wine_quest_pay"],
    [assign,reg(12),"$deliver_wine_quest_pay"],
    [val_mul,reg(12),5],
    [add_xp_as_reward,reg(12)],
    [complete_quest,"qst_deliver_wine"],
    [assign,"$deliver_wine_quest_active",0],
    [assign,reg(5),"$deliver_wine_quest_pay"],
    [str_store_item_name,2,"$deliver_wine_quest_item"],
    [str_store_troop_name,1,"$deliver_wine_quest_giver"],
    [val_add,"$merchants_guild_rank",1]]],

  [anyone|plyr,"tavernkeeper_talk", [[check_quest_active,"qst_deliver_wine"],
                                     [store_encountered_party,reg(7)],
                                     [eq,reg(7),"$deliver_wine_quest_town"],
                                     [store_item_kind_count,reg(8),"$deliver_wine_quest_item"],
                                     [lt,reg(8),"$deliver_wine_quest_number"],
                                     [ge,reg(8),1],
                                     [assign,reg(9),"$deliver_wine_quest_number"],
                                     [str_store_item_name,2,"$deliver_wine_quest_item"],
                                     ],
   "I was told to deliver you {reg9} units of {s2}, but I lost some of the cargo on the way.", "tavernkeeper_deliver_wine_incomplete",[]],
  [anyone,"tavernkeeper_deliver_wine_incomplete", [],
 "Attacked by bandits eh?\
 You are lucky they left you alive.\
 Anyway, I can pay you no more than {reg5} denars for this.\
 And I will let {s1} know that my order was delivered less than completly,\
 so you will probably be charged for this loss.", "tavernkeeper_pretalk",
   [[store_item_kind_count,reg(8),"$deliver_wine_quest_item"],
    [troop_remove_items, 0,"$deliver_wine_quest_item",reg(8)],
    [assign,reg(5),"$deliver_wine_quest_pay"],
    [val_mul,reg(5),reg(8)],
    [val_div,reg(5),"$deliver_wine_quest_number"],
    [troop_add_gold, "trp_player",reg(5)],
    [assign,reg(12),reg(5)],
    [val_mul,reg(12),4],
    [add_xp_as_reward,reg(12)],
    [complete_quest,"qst_deliver_wine"],
    [assign,"$deliver_wine_quest_active",0],
    [str_store_item_name,2,"$deliver_wine_quest_item"],
    [str_store_troop_name,1,"$deliver_wine_quest_giver"],
    [assign,reg(14),"$deliver_wine_quest_debt"],
    [val_mul,reg(14),reg(8)],
    [val_div,reg(14),"$deliver_wine_quest_number"],
    [val_add,"$debt_to_merchants_guild",reg(14)],
   ]],
  [anyone|plyr,"tavernkeeper_talk", [[check_quest_active,"qst_deliver_wine"],
                                     [store_encountered_party,reg(7)],
                                     [eq,reg(7),"$deliver_wine_quest_town"],
                                     [store_item_kind_count,reg(8),"$deliver_wine_quest_item"],
                                     [eq,reg(8),0],
                                     [assign,reg(9),"$deliver_wine_quest_number"],
                                     [str_store_item_name,2,"$deliver_wine_quest_item"],
                                     ],
   "I was told to deliver you {reg9} units of {s2}, but I lost the cargo on the way.", "tavernkeeper_deliver_wine_lost",[]],
  [anyone,"tavernkeeper_deliver_wine_lost", [],
 "What? I was waiting for that {s2} for weeks!\
 And now you are telling me that you lost it?\
 Heck, I am going to let {s1} know about this.", "tavernkeeper_pretalk",
   [[add_xp_as_reward,40],
    [complete_quest,"qst_deliver_wine"],
    [assign,"$deliver_wine_quest_active",0],
    [str_store_item_name,2,"$deliver_wine_quest_item"],
    [str_store_troop_name,1,"$deliver_wine_quest_giver"],
    [val_add,"$debt_to_merchants_guild","$deliver_wine_quest_debt"],
   ]],

  [anyone|plyr,"tavernkeeper_talk", [], "I need to hire some soldiers. Can you help me?", "tavernkeeper_buy_peasants",[]],
  [anyone,"tavernkeeper_buy_peasants",
   [
       (store_encountered_party,reg(3)),
       (store_faction_of_party,reg(4),reg(3)),
       (store_relation,reg(5),"fac_player_faction",reg(4)),
       (lt, reg(5), -3),
    ], "I don't think anyone from this town will follow somebody like you. Try your luck elsewhere.", "tavernkeeper_buy_peasants_2",[]],
  [anyone,"tavernkeeper_buy_peasants", [], "I know a few fellows who would follow you if you paid for their equipment.", "tavernkeeper_buy_peasants_2",[(set_mercenary_source_party,"$tavernkeeper_party"),[change_screen_buy_mercenaries]]],
  [anyone,"tavernkeeper_buy_peasants_2", [], "Anything else?", "tavernkeeper_talk",[]],

  [anyone|plyr,"tavernkeeper_talk", [], "I want to rest for a while.", "tavernkeeper_rest",[]],
#  [anyone,"tavernkeeper_rest", [], "Of course... How long do you want to rest?", "tavernkeeper_rest_2",[]],
  [anyone,"tavernkeeper_rest",
   [
       (store_encountered_party,reg(3)),
       (store_faction_of_party,reg(4),reg(3)),
       (store_relation,reg(5),"fac_player_faction",reg(4)),
       (lt, reg(5), -3),
      ], "You look like trouble stranger. I can't allow you to stay for the night. No.", "close_window",
   []],
  [anyone,"tavernkeeper_rest", [], "Of course... That will be {reg3} denars for the room and food. How long do you want to rest?", "tavernkeeper_rest_2",
   [(store_party_size,reg(3)),
    (val_add,reg(3),1),
    (val_div,reg(3),3),
    (val_max,reg(3),1),
    (assign,"$tavern_rest_cost",reg(3))]],
  [anyone|plyr,"tavernkeeper_rest_2", [(store_time_of_day,reg(1)),(val_add,reg(1),7),(val_mod,reg(1),24),(lt,reg(1),12),(store_troop_gold,reg(8),"trp_player"),(ge,reg(8),"$tavern_rest_cost")],
   "I want to rest until morning.", "close_window",
   [(assign, reg(2), 13),(val_sub,reg(2),reg(1)),(assign, "$g_town_visit_after_rest", 1),(rest_for_hours, reg(2)),(troop_remove_gold, "trp_player","$tavern_rest_cost")]],
  [anyone|plyr,"tavernkeeper_rest_2", [(store_time_of_day,reg(1)),(val_add,reg(1),7),(val_mod,reg(1),24),(ge,reg(1),12),(store_troop_gold,reg(8),"trp_player"),(ge,reg(8),"$tavern_rest_cost")],
   "I want to rest until evening.", "close_window",
   [(assign, reg(2), 28),(val_sub,reg(2),reg(1)),(assign, "$g_town_visit_after_rest", 1),(rest_for_hours, reg(2)),(troop_remove_gold, "trp_player","$tavern_rest_cost")]],
  [anyone|plyr,"tavernkeeper_rest_2", [], "Forget it.", "close_window",[]],

  [anyone|plyr,"tavernkeeper_talk", [], "I guess I should leave now.", "close_window",[]],

#Goods Merchants
  
  [anyone ,"start", [(store_conversation_troop,reg(1)),(ge,reg(1),goods_merchants_begin),(lt,reg(1),goods_merchants_end)],
   "Welcome {sir/madam}.", "merchant_begin",[]],

  [trp_salt_mine_merchant,"start", [], "Hello.", "merchant_begin",[]],

  [anyone,"merchant_begin", [[eq,"$kidnapped_girl_brought_back",1],
                             [store_conversation_troop,reg(7)],
                             [eq,"$kidnapped_girl_quest_giver",reg(7)]],
   "Dear {playername}. I am in your debt for bringing back my friend's daughter.\
  Please take these {reg8} denars that I promised you.\
  My friend wished he could give more but paying that ransom brought him to his knees.", "close_window",
   [[assign,"$kidnapped_girl_brought_back",0],
    [troop_add_gold, "trp_player","$kidnapped_girl_quest_pay"],
    [assign,reg(8),"$kidnapped_girl_quest_pay"],
    [assign,reg(9),"$kidnapped_girl_quest_pay"],
    [val_div,reg(9),2],
    [store_random,reg(11),100],
    [val_add,reg(9),reg(11)],
    [val_mul,reg(9),10],
    [add_xp_as_reward,reg(9)],
    [complete_quest,"qst_kidnapped_girl"],
    [store_conversation_troop,"$merchant_quest_last_offerer"],
    [assign,"$merchant_offered_quest",-1],
    [val_add,"$merchants_guild_rank",1],
    ]],
  
  [anyone,"merchant_begin", [[eq,"$troublesome_bandits_quest_succeeded",1],
                             [store_conversation_troop,reg(7)],
                             [eq,reg(7),"$troublesome_bandits_quest_giver"]],
   "I have heard about your deeds. You have given those bandits the punishment they deserved.\
 You are really as good as they say.\
 Here is your reward: {reg5} denars.\
 I would like to give more but those bandits almost brought me to bankrupcy.", "goods_merchant_friendly_pretalk",
                              [[assign,"$troublesome_bandits_quest_succeeded",0],
                               [complete_quest,"qst_troublesome_bandits"],
                               [assign,reg(5),"$troublesome_bandits_quest_pay"],
                               [troop_add_gold, "trp_player","$troublesome_bandits_quest_pay"],
                               [assign,reg(8),"$troublesome_bandits_quest_pay"],
                               [val_mul,reg(8),7],
                               [add_xp_as_reward,reg(8)],
                               [store_conversation_troop,"$merchant_quest_last_offerer"],
                               [assign,"$merchant_offered_quest",-1],
                               [val_add,"$merchants_guild_rank",1],
                               ]],

  [anyone,"merchant_begin", [[ge,"$debt_to_merchants_guild",50]],
   "According to my accounts, you owe the merchants guild {reg1} denars.\
 I'd better collect that now.", "merchant_ask_for_debts",[[assign,reg(1),"$debt_to_merchants_guild"]]],
  [anyone|plyr,"merchant_ask_for_debts", [[store_troop_gold,reg(5),"trp_player"],[ge,reg(5),"$debt_to_merchants_guild"]],
   "Allright. I'll pay my debt to you.", "merchant_debts_paid",[[troop_remove_gold, "trp_player","$debt_to_merchants_guild"],
                                                                [assign,"$debt_to_merchants_guild",0]]],
  [anyone, "merchant_debts_paid", [], "Excellent. I'll let my fellow merchants know that you are clear of any debts.", "goods_merchant_pretalk",[]],

  [anyone|plyr, "merchant_ask_for_debts", [], "I'm afraid I can't pay that sum now.", "merchant_debts_not_paid",[]],
  [anyone, "merchant_debts_not_paid", [], "In that case, I am afraid, I can't deal with you. Guild rules...\
 Come back when you can pay the {reg1} denars.\
 And know that we'll be charging an interest to your debt.\
 So the sooner you pay it, the better.", "close_window",[]],

  [anyone,"goods_merchant_friendly_pretalk", [], "Now... What else may I do for you?", "goods_merchant_talk",[]],

  [anyone,"merchant_begin", [], " What can I do for you?", "goods_merchant_talk",[]],


  [anyone|plyr,"goods_merchant_talk", [], "I want to buy a few things... and perhaps sell some.", "goods_trade_requested",[]],
  [anyone,"goods_trade_requested", [], "Sure, sure... Let me show you what we have...", "goods_trade_completed",[[change_screen_trade]]],
  [anyone,"goods_trade_completed", [], "Anything else?", "goods_merchant_talk",[]],
  [anyone,"goods_merchant_pretalk", [], "Anything else?", "goods_merchant_talk",[]],
  [anyone|plyr,"goods_merchant_talk", [], "What do caravans buy and sell in this town?", "goods_merchant_town_info",[]],
  [anyone,"goods_merchant_town_info_completed", [], "Anything else?", "goods_merchant_talk",[]],
  
  [anyone|plyr,"goods_merchant_talk", [[store_partner_quest,reg(2)],[lt,reg(2),0],
                                       [store_conversation_troop,reg(5)],
                                       [neq,"$merchant_quest_last_offerer",reg(5)]],
   "Do you happen to have a job for me?", "merchant_quest_requested",[
     [store_conversation_troop,"$merchant_quest_last_offerer"],
     [assign,"$num_merchant_quests_available","$merchants_guild_rank"],
     [assign,"$cur_merchant_quests_end",merchant_quests_begin],
     [val_max,"$num_merchant_quests_available",1],
     [val_add,"$cur_merchant_quests_end","$num_merchant_quests_available"],
     [val_min,"$cur_merchant_quests_end",merchant_quests_end],
     [store_random_quest_in_range,reg(0),merchant_quests_begin,"$cur_merchant_quests_end"],
     [assign,"$random_merchant_quest_no",reg(0)],
     [assign,"$merchant_offered_quest","$random_merchant_quest_no"],
     ]],
  [anyone|plyr,"goods_merchant_talk", [[store_partner_quest,reg(2)],[lt,reg(2),0],
                                       [store_conversation_troop,reg(5)],
                                       [eq,"$merchant_quest_last_offerer",reg(5)],
                                       [ge,"$merchant_offered_quest",0]], "About that job you offered me...", "merchant_quest_last_offered_job",[]],

  [anyone|plyr,"goods_merchant_talk", [[store_partner_quest,reg(2)],[ge,reg(2),0]],
   "About the job you gave me...", "merchant_quest_about_job",[]],
  [anyone,"merchant_quest_about_job", [], "What about it?", "merchant_quest_about_job_2",[]],
  [anyone|plyr,"merchant_quest_about_job_2", [], "What if I can't finish it?", "merchant_quest_what_if_fail",[]],
  [anyone|plyr,"merchant_quest_about_job_2", [], "Well, I'm still working on it.", "merchant_quest_about_job_working",[]],
  [anyone,"merchant_quest_about_job_working", [], "Good. I'm sure you will handle it.", "goods_merchant_pretalk",[]],


  [anyone,"merchant_quest_last_offered_job", [], "Eh, you want to reconsider that. Good...", "merchant_quest_brief",
   [[assign,"$random_merchant_quest_no","$merchant_offered_quest"]]],


  [anyone,"merchant_quest_what_if_fail", [[store_partner_quest,reg(2)],[eq,reg(2),"qst_deliver_wine"]],
   "I hope you don't fail. In that case, I'll have to ask for the price of the cargo you were carrying.", "goods_merchant_pretalk",[]],
  [anyone,"merchant_quest_what_if_fail", [], "Well, just do your best to finish it.", "goods_merchant_pretalk",[]],

  [anyone|plyr,"goods_merchant_talk", [], "Nothing. Thanks.", "close_window",[]],

  [anyone,"merchant_quest_taken", [], "Excellent. I am counting on you then. Good luck.", "goods_merchant_pretalk",
   [[assign,"$merchant_quest_last_offerer",0]]],
  [anyone,"merchant_quest_stall", [], "Well, the job will be available for a few more days I guess. Tell me if you decide to take it.", "goods_merchant_pretalk",[]],

###################################################################3
# Random Merchant quests....
##############################
  # deliver wine:
  [anyone,"merchant_quest_requested", [[eq,"$random_merchant_quest_no","qst_deliver_wine"],], "You're looking for a job?\
 Actually I was looking for someone to deliver some {s2}.\
 Perhaps you can do that...", "merchant_quest_brief",
   [
    [store_random_party_in_range, reg(0),towns_begin,towns_end],
    [assign,"$deliver_wine_quest_town", reg(0)],
    [store_random,"$deliver_wine_quest_item",6],
    [val_add,"$deliver_wine_quest_item","itm_dried_meat"],
    [store_random,"$deliver_wine_quest_number",6],
    [val_add,"$deliver_wine_quest_number",6],
    [str_store_item_name,2,"$deliver_wine_quest_item"],
    [store_conversation_troop,"$deliver_wine_quest_giver"],
    [store_encountered_party,"$deliver_wine_quest_giver_town"],
    [store_distance_to_party_from_party, reg(0),"$deliver_wine_quest_giver_town","$deliver_wine_quest_town"],
    [assign,"$deliver_wine_quest_pay",reg(0)],
    [val_add,"$deliver_wine_quest_pay",2],
    [assign,reg(10),5],
    [val_add,reg(10),"$deliver_wine_quest_number"],
    [val_mul,"$deliver_wine_quest_pay",reg(10)],
#    [val_mul,"$deliver_wine_quest_pay",2],
#    [val_div,"$deliver_wine_quest_pay",3],
    [val_div,"$deliver_wine_quest_pay",100],
    [val_mul,"$deliver_wine_quest_pay",10],
    [store_item_value,"$deliver_wine_quest_debt","$deliver_wine_quest_item"],
    [val_mul,"$deliver_wine_quest_debt","$deliver_wine_quest_number"],
    [val_mul,"$deliver_wine_quest_debt",6],
    [val_div,"$deliver_wine_quest_debt",5],
    ]],

  [anyone,"merchant_quest_brief", [[eq,"$random_merchant_quest_no","qst_deliver_wine"]],
   "I have a cargo of {s6} that needs to be delivered to the tavern in {s2}.\
 If you can take {reg5} units of {s6} to {s2} in 7 days, you may earn {reg8} denars.\
 What do you say?", "merchant_quest_brief_deliver_wine",[
     [assign,reg(8),"$deliver_wine_quest_pay"],
     [assign,reg(5),"$deliver_wine_quest_number"],
     [str_store_troop_name,1,"$deliver_wine_quest_giver"],
     [str_store_party_name,2,"$deliver_wine_quest_town"],
     [str_store_item_name,6,"$deliver_wine_quest_item"],
     [setup_quest_text,"qst_deliver_wine"],
   ]],
  
  [anyone|plyr,"merchant_quest_brief_deliver_wine", [[store_free_inventory_capacity,reg(6)],[ge,reg(6),"$deliver_wine_quest_number"]],
      "Allright. I will make the delivery.", "merchant_quest_taken",[
        [assign,"$deliver_wine_quest_active",1],
        [assign,"$deliver_wine_quest_cancelled",0],
        [store_current_day, "$deliver_wine_quest_end_day"],
        [val_add,"$deliver_wine_quest_end_day",7],
        [troop_add_items,  0,"$deliver_wine_quest_item","$deliver_wine_quest_number"],
        [start_quest,"qst_deliver_wine"],
        ]],
  [anyone|plyr,"merchant_quest_brief_deliver_wine", [], "I am afraid I can't carry all that cargo now.", "merchant_quest_stall",[]],

#escort merchant caravan:
  [anyone,"merchant_quest_requested", [[eq,"$random_merchant_quest_no","qst_escort_merchant_caravan"]], "You're looking for a job?\
 Actually I was looking for someone to escort a caravan.\
 Perhaps you can do that...", "merchant_quest_brief",
   [
    [store_random_party_in_range, reg(0),towns_begin,towns_end],
    [assign,"$escort_merchant_caravan_quest_town", reg(0)],
    [store_conversation_troop,"$escort_merchant_caravan_quest_giver"],
    [store_encountered_party,"$escort_merchant_caravan_quest_giver_town"],
    [assign,"$escort_merchant_caravan_quest_pay",200],
    [store_distance_to_party_from_party, reg(0),"$escort_merchant_caravan_quest_giver_town","$escort_merchant_caravan_quest_town"],
    [assign,"$escort_merchant_caravan_quest_pay",reg(0)],
    [val_add,"$escort_merchant_caravan_quest_pay",25],
    [val_mul,"$escort_merchant_caravan_quest_pay",25],
    [val_div,"$escort_merchant_caravan_quest_pay",2],
    [val_div,"$escort_merchant_caravan_quest_pay",10],
    [val_mul,"$escort_merchant_caravan_quest_pay",1],
    [store_random,"$escort_merchant_min_size",6],
    [val_add,"$escort_merchant_min_size",6],
    ]],

  [anyone,"merchant_quest_brief", [[eq,"$random_merchant_quest_no","qst_escort_merchant_caravan"]],
   "I am going to send a caravan of goods to {s1}.\
 However with all those bandits and deserters on the roads, I don't want to send them out without an escort.\
 If you can lead that caravan to {s1} in 15 days, you will earn {reg8} denars.\
 Of course your party needs to be at least {reg4} strong to offer them any protection.", "escort_merchant_caravan_quest_brief",[
     [assign,reg(8),"$escort_merchant_caravan_quest_pay"],
     [assign,reg(4),"$escort_merchant_min_size"],
     [str_store_party_name,1,"$escort_merchant_caravan_quest_town"],
   ]],
  
  [anyone|plyr,"escort_merchant_caravan_quest_brief", [[store_party_size_wo_prisoners,reg(6)],[ge,reg(6),"$escort_merchant_min_size"]],
      "Allright. I will escort the caravan.", "merchant_quest_taken",[
        [assign,"$escort_merchant_caravan_quest_active",1],
        [store_current_day, "$escort_merchant_caravan_quest_end_day"],
        [val_add,"$escort_merchant_caravan_quest_end_day",15],
        [set_spawn_radius,1],
        [spawn_around_party,"$escort_merchant_caravan_quest_giver_town","pt_merchant_caravan"],
        [assign,"$merchant_caravan_id",reg(0)],
        [party_set_ai_behavior,"$merchant_caravan_id",ai_bhvr_track_party],
        [party_set_ai_object,"$merchant_caravan_id",0],
        [assign,"$merchant_caravan_met",0],
        [str_store_party_name,1,"$escort_merchant_caravan_quest_town"],
        [setup_quest_text,"qst_escort_merchant_caravan"],
        [start_quest,"qst_escort_merchant_caravan"],
    ]],
  [anyone|plyr,"escort_merchant_caravan_quest_brief", [[store_party_size_wo_prisoners,reg(6)],[lt,reg(6),"$escort_merchant_min_size"]],
   "I am afraid I don't have that many soldiers with me.", "merchant_quest_stall",[]],
  [anyone|plyr,"escort_merchant_caravan_quest_brief", [[store_party_size,reg(6)],[ge,reg(6),"$escort_merchant_min_size"]],
   "Sorry. I can't do that right now", "merchant_quest_stall",[]],

  [party_tpl|pt_merchant_caravan,"start", [[store_encountered_party,reg(11)],
                                                     [eq,reg(11),"$merchant_caravan_id"],
                                                     [eq,"$escort_merchant_caravan_quest_active",2]],
   "We can cover the rest of the way ourselves. Thanks.", "close_window",[(assign, "$g_leave_encounter",1)]],
  
  [party_tpl|pt_merchant_caravan,"start", [[store_encountered_party,reg(11)],
                                                     [eq,reg(11),"$merchant_caravan_id"],
                                                     [store_distance_to_party_from_party, reg(0),"$escort_merchant_caravan_quest_town","$merchant_caravan_id"],
                                                     [lt,reg(0),4],
                                                     [eq,"$escort_merchant_caravan_quest_active",1]],
   "Well, we have almost reached {s1}. We can cover the rest of the way ourselves.\
 Here's your pay... {reg4} denars.\
 Thanks for escorting us. Good luck.", "close_window",[[party_set_ai_behavior,"$merchant_caravan_id",ai_bhvr_travel_to_party],
                                                       [party_set_ai_object,"$merchant_caravan_id","$escort_merchant_caravan_quest_town"],
                                                       [str_store_party_name,1,"$escort_merchant_caravan_quest_town"],
                                                       [complete_quest,"qst_escort_merchant_caravan"],
                                                       [assign,"$escort_merchant_caravan_quest_active",2],
                                                       [troop_add_gold, "trp_player","$escort_merchant_caravan_quest_pay"],
                                                       [assign,reg(7),"$escort_merchant_caravan_quest_pay"],
                                                       [val_mul,reg(7),5],
                                                       [val_add,reg(7),100],
                                                       [add_xp_as_reward,reg(7)],
                                                       [assign,reg(4),"$escort_merchant_caravan_quest_pay"],
                                                       [val_add,"$merchants_guild_rank",1],
                                                       (assign, "$g_leave_encounter",1)]],
  
  [party_tpl|pt_merchant_caravan,"start", [[store_encountered_party,reg(11)],
                                                     [eq,reg(11),"$merchant_caravan_id"],
                                                     [eq,"$merchant_caravan_met",0]],
   "Greetings. You must be our escort, right?", "merchant_caravan_intro_1",[[assign,"$merchant_caravan_met",1]]],
  [anyone|plyr,"merchant_caravan_intro_1", [], "Yes. My name is {playername}. I will lead you to {s1}.", "merchant_caravan_intro_2",[[str_store_party_name,1,"$escort_merchant_caravan_quest_town"]]],
  [anyone,"merchant_caravan_intro_2", [], "Well, It is good to know we won't travel alone. What do you want us to do now?", "escort_merchant_caravan_talk",[]],
  [party_tpl|pt_merchant_caravan,"start", [[store_encountered_party,reg(11)],
                                                     [eq,reg(11),"$merchant_caravan_id"]],
   "Eh. We've made it this far... What do you want us to do?", "escort_merchant_caravan_talk",[]],
  [anyone|plyr,"escort_merchant_caravan_talk", [], "You follow my lead. I'll take you through a safe route.", "merchant_caravan_follow_lead",[]],
  [anyone,"merchant_caravan_follow_lead", [], "Allright. We'll be right behind you.", "close_window",[(assign,"$escort_merchant_caravan_mode",0),(assign, "$g_leave_encounter",1)]],
  [anyone|plyr,"escort_merchant_caravan_talk", [], "You stay here for a while. I'll go ahead and check the road.", "merchant_caravan_stay_here",[]],
  [anyone,"merchant_caravan_stay_here", [], "Allright. We'll be waiting here for you.", "close_window",[(assign,"$escort_merchant_caravan_mode",1),(assign, "$g_leave_encounter",1)]],
#  [anyone|plyr,"escort_merchant_caravan_talk", [], "You go ahead to {s1}. I'll catch up with you.", "merchant_caravan_go_to_destination",[]],
#  [anyone,"merchant_caravan_go_to_destination", [], "Allright. But stay close.", "close_window",[[assign,"escort_merchant_caravan_mode",2]]],


# Troublesome bandits:
  [anyone,"merchant_quest_requested", [[eq,"$random_merchant_quest_no","qst_troublesome_bandits"]],
 "Actually, I was looking for an able adventurer like you.\
 There's this group of particularly troublesome bandits.\
 They have infested the vicinity of our town and are preying on my caravans.\
 They have avoided all the soldiers and the militias up to now.\
 If someone doesn't stop them soon, I am going to be ruined...", "merchant_quest_brief",
   [
    [store_conversation_troop,"$troublesome_bandits_quest_giver"],
    [store_encountered_party,"$troublesome_bandits_quest_giver_town"],
    [store_character_level,reg(7)],
    [val_add,reg(7),20],
    [val_mul,reg(7),35],
    [assign,"$troublesome_bandits_quest_pay",reg(7)],
    [val_div,"$troublesome_bandits_quest_pay",100],
    [val_mul,"$troublesome_bandits_quest_pay",10],
    ]],

  [anyone,"merchant_quest_brief", [[eq,"$random_merchant_quest_no","qst_troublesome_bandits"]],
  "I will pay you {reg8} denars if you hunt down those troublesome bandits.\
 It's dangerous work. But I believe that you are the {man/one} for it.\
 What do you say?", "troublesome_bandits_quest_brief",[
     [assign,reg(8),"$troublesome_bandits_quest_pay"],
   ]],

  [anyone|plyr,"troublesome_bandits_quest_brief", [],
      "Allright. I will hunt down those bandits.", "merchant_quest_taken_bandits",[
        [assign,"$troublesome_bandits_quest_active",1],
        [assign,"$troublesome_bandits_quest_succeeded",0],
        [set_spawn_radius,7],
        [spawn_around_party,"$troublesome_bandits_quest_giver_town","pt_troublesome_bandits"],
        [assign,"$troublesome_bandits_id",reg(0)],
        [store_num_parties_destroyed,"$troublesome_bandits_eliminated","pt_troublesome_bandits"],
        (store_num_parties_destroyed_by_player, "$troublesome_bandits_eliminated_by_player", "pt_troublesome_bandits"),
        [str_store_troop_name,1,"$troublesome_bandits_quest_giver"],
        [str_store_party_name,2,"$troublesome_bandits_quest_giver_town"],
        [setup_quest_text,"qst_troublesome_bandits"],
        [start_quest,"qst_troublesome_bandits"],
    ]],
  [anyone,"merchant_quest_taken_bandits", [], "You will? I am so happy to hear that. Good luck to you.", "goods_merchant_friendly_pretalk",
   [[assign,"$merchant_quest_last_offerer",0]]],
  
  [anyone|plyr,"troublesome_bandits_quest_brief", [],
   "Sorry. I don't have time for this right now.", "merchant_quest_stall",[]],

  [party_tpl|pt_troublesome_bandits,"start", [[store_encountered_party,reg(11)],
                                                        [eq,reg(11),"$troublesome_bandits_id"]],
   "This must be your unlucky day indeed. We are the baddest guys you coud have run into in these parts...", "troublesome_bandits_intro_1",[]],
  [anyone|plyr,"troublesome_bandits_intro_1", [],
   "Heh. For me, you are nothing more than walking money bags.\
 A merchant in {s1} offered me good money for your heads.", "troublesome_bandits_intro_2",[[str_store_party_name,1,"$troublesome_bandits_quest_giver_town"]]],
  [anyone,"troublesome_bandits_intro_2", [],
   "A bounty hunter! ... I hate bounty hunters! Kill {him/her}! Kill {him/her} now!", "close_window",[(encounter_attack)]],

# Kidnapped girl:
  [anyone,"merchant_quest_requested", [[eq,"$random_merchant_quest_no","qst_kidnapped_girl"]],
 "Actually, I was looking for a reliable {man/helper} that can undertake an important mission.\
 A group of bandits have kidnapped the daughter of a friend of mine and are holding her for ransom.\
 My friend is ready to pay them, but we still need\
 someone to take the money to those rascals and bring the girl back to safety.", "merchant_quest_brief",
   [
    [store_random_party_in_range, reg(0),towns_begin,towns_end],
    [assign,"$kidnapped_girl_quest_town", reg(0)],
    [store_conversation_troop,"$kidnapped_girl_quest_giver"],
    [store_encountered_party,"$kidnapped_girl_quest_giver_town"],
    [store_character_level,reg(7)],
    [val_add,reg(7),15],
    [store_distance_to_party_from_party, reg(0),"$kidnapped_girl_quest_giver_town","$kidnapped_girl_quest_town"],
    [val_add,reg(0),15],
    [val_mul,reg(0),2],
    [val_mul,reg(7),reg(0)],
    [assign,"$kidnapped_girl_ransom_amount",reg(7)],
    [assign,"$kidnapped_girl_quest_pay","$kidnapped_girl_ransom_amount"],
    [val_div,"$kidnapped_girl_quest_pay",4],
    [val_div,"$kidnapped_girl_quest_pay",100],
    [val_mul,"$kidnapped_girl_quest_pay",10],
    [val_div,"$kidnapped_girl_ransom_amount",100],
    [val_mul,"$kidnapped_girl_ransom_amount",10],
    ]],

  [anyone,"merchant_quest_brief", [[eq,"$random_merchant_quest_no","qst_kidnapped_girl"]],
  "The amount the bandits ask as ransom is {reg12} denars.\
 I will give you that money once you accept to take the quest.\
 You have 15 days to take the money to the bandits who will be waiting near the town of {s2}.\
 Those bastards said that they are going to kill the poor girl if they don't get the money by that time.\
 You will get your pay of {reg8} denars when you bring the girl safely back here.",
   "kidnapped_girl_quest_brief",[
     [str_store_party_name,2,"$kidnapped_girl_quest_town"],
     [assign,reg(8),"$kidnapped_girl_quest_pay"],
     [assign,reg(12),"$kidnapped_girl_ransom_amount"],
   ]],

  [anyone|plyr,"kidnapped_girl_quest_brief", [],
      "Allright. I will take the ransom money to the bandits and bring back the girl.", "kidnapped_girl_quest_taken",[
        [assign,"$kidnapped_girl_quest_active",1],
        [set_spawn_radius,4],
        [spawn_around_party,"$kidnapped_girl_quest_town","pt_bandits_awaiting_ransom"],
        [assign,"$kidnapped_girl_bandits_id",reg(0)],
        [party_set_ai_behavior,"$kidnapped_girl_bandits_id",ai_bhvr_hold],
        [party_set_ai_object,"$kidnapped_girl_bandits_id",0],
        [troop_add_gold, "trp_player","$kidnapped_girl_ransom_amount"],
        [assign,"$kidnapped_girl_freed",0],
        [assign,"$kidnapped_girl_bandits_introd",0],
        [assign,"$kidnapped_girl_joined",0],
        [assign,"$kidnapped_girl_bandits_attacked",0],
        [assign,reg(12),"$kidnapped_girl_ransom_amount"],
        [str_store_troop_name,1,"$kidnapped_girl_quest_giver"],
        [str_store_party_name,2,"$kidnapped_girl_quest_giver_town"],
        [str_store_party_name,3,"$kidnapped_girl_quest_town"],
        [setup_quest_text,"qst_kidnapped_girl"],
        [start_quest,"qst_kidnapped_girl"],
    ]],
  [anyone,"kidnapped_girl_quest_taken", [], "Good. I knew we could trust you at this.\
 Here is the ransom money, {reg12} denars.\
 Count it before taking it.\
 And please, don't attempt to do anything rash.\
 Keep in mind that the girl's well being is more important than anything else...", "close_window",
   [[assign,"$merchant_quest_last_offerer",0]]],
  
  [anyone|plyr,"kidnapped_girl_quest_brief", [],
   "Sorry. I don't have time for this right now.", "merchant_quest_stall",[]],


  [anyone,"start", [(eq, "$talk_context", tc_hero_freed),(store_conversation_troop,":cur_troop"),(eq,":cur_troop","trp_kidnapped_girl"),],
   "Oh {sir/madam}. Thank you so much for rescuing me. Will you take me to my family now?", "kidnapped_girl_liberated_battle",[]],

  [trp_kidnapped_girl|plyr,"kidnapped_girl_liberated_map", [], "Yes. Come with me. We are going home.", "kidnapped_girl_liberated_map_2a",[]],
  [trp_kidnapped_girl,"kidnapped_girl_liberated_map_2a", [[neg|party_can_join]], "Unfortunately. You do not have room in your party for me.", "close_window",[(assign, "$g_leave_encounter",1)]],
  [trp_kidnapped_girl,"kidnapped_girl_liberated_map_2a", [], "Oh really? Thank you so much!", "close_window",[(party_join),(assign,"$kidnapped_girl_joined",1),(assign, "$g_leave_encounter",1)]],
  [trp_kidnapped_girl|plyr,"kidnapped_girl_liberated_map", [], "Wait here a while longer. I'll come back for you.", "kidnapped_girl_liberated_map_2b",[]],
  [trp_kidnapped_girl,"kidnapped_girl_liberated_map_2b", [], "Oh, please {sir/madam}, do not leave me here all alone!", "close_window",[(assign, "$g_leave_encounter",1)]],


  [trp_kidnapped_girl,"start", [],
   "Oh {sir/madam}. Thank you so much for rescuing me. Will you take me to my family now?", "kidnapped_girl_liberated_map",[]],
  
  [trp_kidnapped_girl|plyr,"kidnapped_girl_liberated_battle", [], "Yes. Come with me. We are going home.", "kidnapped_girl_liberated_battle_2a",[]],
  [trp_kidnapped_girl,"kidnapped_girl_liberated_battle_2a", [[neg|hero_can_join]], "Unfortunately. You do not have room in your party for me.", "kidnapped_girl_liberated_battle_2b",[]],
  [trp_kidnapped_girl,"kidnapped_girl_liberated_battle_2a", [], "Oh really? Thank you so much!", "close_window",[(party_add_members, "p_main_party","trp_kidnapped_girl",1),(assign,"$kidnapped_girl_joined",1)]],
  [trp_kidnapped_girl|plyr,"kidnapped_girl_liberated_battle", [], "Wait here a while longer. I'll come back for you.", "kidnapped_girl_liberated_battle_2b",[]],
  [trp_kidnapped_girl,"kidnapped_girl_liberated_battle_2b", [], "Oh, please {sir/madam}, do not leave me here all alone!", "close_window",[(add_companion_party,"trp_kidnapped_girl"),(assign, "$g_leave_encounter",1)]],

  [trp_kidnapped_girl,"start", [], "Can I come with you now?", "kidnapped_girl_liberated_map",[]],

  [trp_kidnapped_girl,"member_chat", [], "Are we home yet?", "kidnapped_girl_chat_1",[]],
  [trp_kidnapped_girl|plyr,"kidnapped_girl_chat_1", [], "No not yet.", "kidnapped_girl_chat_2",[]],
  [trp_kidnapped_girl,"kidnapped_girl_chat_2", [], "I missed my family so much. I can't wait to see them again.", "close_window",[]],


  [party_tpl|pt_bandits_awaiting_ransom,"start", [[eq,"$kidnapped_girl_freed",0],[eq,"$kidnapped_girl_bandits_introd",0]],
   "Are you the one that brought the ransom?\
 Quick, give us the money now.", "bandits_awaiting_ransom_intro_1",[[assign,"$kidnapped_girl_bandits_introd",1]]],
  [party_tpl|pt_bandits_awaiting_ransom,"start", [[eq,"$kidnapped_girl_freed",0]],
   "You came back?\
 Quick, give us the money now.", "bandits_awaiting_ransom_intro_1",[]],
  [party_tpl|pt_bandits_awaiting_ransom|plyr, "bandits_awaiting_ransom_intro_1", [[store_troop_gold,reg(14)],[ge,reg(14),"$kidnapped_girl_ransom_amount"]],
   "Here, take the money. Just set the girl free.", "bandits_awaiting_ransom_pay",[]],
  [party_tpl|pt_bandits_awaiting_ransom, "bandits_awaiting_ransom_pay", [[store_troop_gold,reg(14)],[ge,reg(14),"$kidnapped_girl_ransom_amount"]],
   "Heh. You've brought the money all right.\
 You can take the girl now.\
 It was a pleasure doing business with you...", "close_window",
   [[troop_remove_gold, "trp_player","$kidnapped_girl_ransom_amount"],
    [remove_member_from_party,"trp_kidnapped_girl","$kidnapped_girl_bandits_id"],
    [set_spawn_radius,1],
    [spawn_around_party,"$kidnapped_girl_bandits_id","pt_kidnapped_girl"],
    [assign,"$kidnapped_girl_party_id",reg(0)],
    [party_set_ai_behavior,"$kidnapped_girl_party_id",ai_bhvr_hold],
    [assign,"$kidnapped_girl_freed",1],
    [party_set_ai_behavior,"$kidnapped_girl_bandits_id",ai_bhvr_travel_to_party],
    [party_set_ai_object,"$kidnapped_girl_bandits_id","$kidnapped_girl_quest_town"],
    [add_gold_to_party,"$kidnapped_girl_ransom_amount","$kidnapped_girl_bandits_id"],
    (assign, "$g_leave_encounter",1),
    ]],
  [anyone|plyr, "bandits_awaiting_ransom_intro_1", [],
   "No way! You release the girl first.", "bandits_awaiting_ransom_b",[]],
  [anyone, "bandits_awaiting_ransom_b", [],
   "You fool! Stop playing games and give us the money! ", "bandits_awaiting_ransom_b2",[]],
  [anyone|plyr, "bandits_awaiting_ransom_b2", [[store_troop_gold,reg(14)],[ge,reg(14),"$kidnapped_girl_ransom_amount"]],
   "All right. Here's your money. Let the girl go now.", "bandits_awaiting_ransom_pay",[]],
  [anyone|plyr, "bandits_awaiting_ransom_b2", [],
   "I had left the money in a safe place. Let me go fetch it.", "bandits_awaiting_ransom_no_money",[]],
  [anyone, "bandits_awaiting_ransom_no_money", [],
   "Are you testing our patience or something?  Go and bring that money here quickly.", "close_window",[(assign, "$g_leave_encounter",1)]],
  [anyone|plyr, "bandits_awaiting_ransom_b2", [],
#   "Release the girl at once or face the consequences!", "bandits_awaiting_ransom_fight",[]],
   "I have no intention to pay you anything. I demand that you release the girl now!", "bandits_awaiting_ransom_fight",[]],
  [anyone, "bandits_awaiting_ransom_fight", [],
   "You won't be demanding anything when you're dead.", "close_window",[[encounter_attack],[assign,"$kidnapped_girl_bandits_attacked",1],]],
#  [anyone|plyr, "bandits_awaiting_ransom_fight_2", [[store_troop_gold,reg(14)],[ge,reg(14),"$kidnapped_girl_ransom_amount"]],
#   "All right. Here's your money. Let the girl go now.", "bandits_awaiting_ransom_pay",[]],
#  [anyone|plyr, "bandits_awaiting_ransom_fight_2", [],
#   "Empty threats? No. I'll pay it to you with cold steel...", "close_window",[[encounter_attack]]],

  [party_tpl|pt_bandits_awaiting_ransom,"start", [[eq,"$kidnapped_girl_freed",1]],
   "What's it? You have given us the money. We have no more business.", "bandits_awaiting_remeet",[]],
  [anyone|plyr,"bandits_awaiting_remeet", [],
   "Sorry to bother you. I'll be on my way now.", "close_window",[(assign, "$g_leave_encounter",1)]],
  [anyone|plyr,"bandits_awaiting_remeet", [],
   "We have one more business. You'll give the money back to me.", "bandits_awaiting_remeet_2",[]],
  [anyone,"bandits_awaiting_remeet_2", [],
   "Oh, that business! Of course. Let us get down to it.", "close_window",[[encounter_attack]]],

  [party_tpl|pt_kidnapped_girl,"start", [],
   "Oh {sir/madam}. Thank you so much for rescuing me. Will you take me to my family now?", "kidnapped_girl_encounter_1",[]],
  [anyone|plyr,"kidnapped_girl_encounter_1", [], "Yes. Come with me. I'll take you home.", "kidnapped_girl_join",[]],
  [anyone,"kidnapped_girl_join", [[neg|party_can_join]], "Unfortunately. You do not have room in your party for me.", "close_window",[(assign, "$g_leave_encounter",1)]],
  [anyone,"kidnapped_girl_join", [], "Oh, thank you so much!", "close_window",[[party_join],[assign,"$kidnapped_girl_joined",1],(assign, "$g_leave_encounter",1)]],
  [anyone|plyr,"kidnapped_girl_encounter_1", [], "Wait here a while longer. I'll come back for you.", "kidnapped_girl_wait",[]],
  [anyone,"kidnapped_girl_wait", [], "Oh, please {sir/madam}, do not leave me here all alone!", "close_window",[(assign, "$g_leave_encounter",1)]],

  [trp_kidnapped_girl,"event_triggered", [[eq,"$talking_with_kidnapped_girl",1]],
   "Thank you so much for bringing me back!\
  I can't wait to see my family. Good-bye.",
   "close_window",[[remove_member_from_party,"trp_kidnapped_girl"]]],

  [anyone|plyr,"merchant_quest_about_job_2", [[store_partner_quest,reg(2)],[eq,reg(2),"qst_kidnapped_girl"],
                                              [eq,"$kidnapped_girl_joined",1],
                                              [neg|main_party_has_troop,"trp_kidnapped_girl"]],
   "Unfortunately I lost the girl on the way here...", "lost_kidnapped_girl",[]],
  [anyone,"lost_kidnapped_girl", [],
   "Oh no! How am I going to tell this to my friend?", "lost_kidnapped_girl_2",[]],
  [anyone|plyr,"lost_kidnapped_girl_2", [],
   "I'm sorry. I could do nothing about it.", "lost_kidnapped_girl_3",[]],
  [anyone,"lost_kidnapped_girl_3", [],
   "You let me down {playername}. I had trusted you.\
 I will let people know of your incompetence at this task.\
 Also, I want back that {reg8} denars I gave you as the ransom fee.", "lost_kidnapped_girl_4",
   [[assign,reg(8),"$kidnapped_girl_ransom_amount"],
    [complete_quest,"qst_kidnapped_girl"],
    [store_conversation_troop,"$merchant_quest_last_offerer"],
    [assign,"$merchant_offered_quest",-1],
    [val_sub,"$merchants_guild_rank",4],
    ]],
  [anyone|plyr,"lost_kidnapped_girl_4", [[store_troop_gold,reg(11)],[ge,reg(11),"$kidnapped_girl_ransom_amount"]],
   "Of course. Here you are...", "merchant_quest_about_job_5a",[[troop_remove_gold, "trp_player","$kidnapped_girl_ransom_amount"]]],
  [anyone,"merchant_quest_about_job_5a", [],
   "At least you have the decency to return the money.", "close_window",[]],
  [anyone|plyr,"lost_kidnapped_girl_4", [],
   "Sorry. I don't have that amount with me.", "merchant_quest_about_job_5b",[]],
  [anyone,"merchant_quest_about_job_5b", [],
   "Do you expect me to believe that? You are going to pay that ransom fee back! Go and bring the money now!", "close_window",[
     [val_add,"$debt_to_merchants_guild","$kidnapped_girl_ransom_amount"]]],


#  Give us the money now. Quick.
# Here, take the money. Just set the girl free.
# Heh, It was a pleasure doing business with you. 
  
# You set the girl free first. You'll have the money afterwards.
# Stop playing games.  

################################################# 
#################### Random merchant quests end

  [anyone,"merchant_quest_requested", [], "I am afraid I can't offer you a job right now.", "goods_merchant_pretalk",[]],

  [anyone,"goods_merchant_town_info", [(store_encountered_party,reg(1)),(eq,reg(1),"p_zendar")],
"You can buy tools from here at a very good price.\
 The best place to sell them would be Tulga. Heard they pay quite well for tools  over there.\
 And next time you come here bring some salt. I will pay well for salt.", "goods_merchant_town_info_completed",[]],
  [anyone,"goods_merchant_town_info", [(store_encountered_party,reg(1)),(eq,reg(1),"p_town_1")],
"Sargoth is famous for its fine linen. Many caravans come here to buy that.\
 I heard you can sell it at Halmar and make a nice profit.\
 And next time you come here bring some iron. I will pay well for iron.", "goods_merchant_town_info_completed",[]],
  [anyone,"goods_merchant_town_info", [[store_encountered_party,reg(1)],[eq,reg(1),"p_town_2"]],
"I can sell you some smoked fish with a special price.\
 I heard that caravans take smoked fish to Uxkhal and make a good profit.\
 And next time you come here bring some wool. I will pay you well for wool.", "goods_merchant_town_info_completed",[]],
  [anyone,"goods_merchant_town_info", [[store_encountered_party,reg(1)],[eq,reg(1),"p_town_3"]],
"I can sell you some wine with a special price.\
 I heard that caravans buy wine from here and sell it at Wercheg, making a good profit.\
 And next time you come here, bring some dried meat. I will pay you well for dried meat.", "goods_merchant_town_info_completed",[]],
  [anyone,"goods_merchant_town_info", [[store_encountered_party,reg(1)],[eq,reg(1),"p_town_4"]],
"I have a stock of oil which I can sell you with a good price.\
 They say they offer a fortune for oil in Rivacheg, so maybe you can sell it there.\
 And next time you come here, bring some furs. I will pay you well for furs.", "goods_merchant_town_info_completed",[]],
  [anyone,"goods_merchant_town_info", [[store_encountered_party,reg(1)],[eq,reg(1),"p_town_5"]],
"Jelkala is famous for its velvet. Many caravans come here to buy that.\
 They say merchants will buy it at insane prices in Reyvadin, so maybe you can take it there.\
 And next time you come here, bring some pottery. I will pay you well for pottery.", "goods_merchant_town_info_completed",[]],
  [anyone,"goods_merchant_town_info", [[store_encountered_party,reg(1)],[eq,reg(1),"p_town_6"]],
"We produce some excellent ale here in Praven. Most caravans come here to buy that.\
 They say that the folks at Khudan will sell their right arms for ale, so maybe you can take it there.\
 And next time you come here, bring some spice. I have sold out my stock of spice and I will pay you well for it.", "goods_merchant_town_info_completed",[]],
  [anyone,"goods_merchant_town_info", [[store_encountered_party,reg(1)],[eq,reg(1),"p_town_7"]],
"We produce mostly wheat here in Uxkhal. I would suggest you buy that.\
 I heard you can sell it with a good profit in Tulga, so maybe you can take it there.\
 And next time you come here, bring some smoked fish. I will pay you well for it.", "goods_merchant_town_info_completed",[]],

  [anyone,"goods_merchant_town_info", [[store_encountered_party,reg(1)],[eq,reg(1),"p_town_8"]],
"Most caravans come to Reyvadin to buy wool.\
 I heard that they take it to Tihr where they pay well for wool.\
 And next time you come here, bring some velvet. I will buy it from you at a good price.", "goods_merchant_town_info_completed",[]],
  [anyone,"goods_merchant_town_info", [[store_encountered_party,reg(1)],[eq,reg(1),"p_town_9"]],
"Most caravans come to Khudan to buy furs.\
 I heard that they take it to Suno where they pay well for it.\
 And next time you come here, bring some ale. I will buy it from you at a good price.", "goods_merchant_town_info_completed",[]],
  [anyone,"goods_merchant_town_info", [[store_encountered_party,reg(1)],[eq,reg(1),"p_town_10"]],
"Most caravans come to Tulga to buy spice.\
 They say that in Praven they pay well for spice, so you may think of selling it to the mechants there.\
 And next time you come here, bring some wheat. I will buy it from you at a good price.", "goods_merchant_town_info_completed",[]],
  [anyone,"goods_merchant_town_info", [[store_encountered_party,reg(1)],[eq,reg(1),"p_town_11"]],
"We mine a lot of iron here in Curaw. I would suggest you buy that.\
 I heard you can take it to Sargoth and sell it with a good profit.\
 And next time you come here, bring some dried meat. I will pay you well for it.", "goods_merchant_town_info_completed",[]],
  [anyone,"goods_merchant_town_info", [[store_encountered_party,reg(1)],[eq,reg(1),"p_town_12"]],
"I can sell you some smoked fish with a special price.\
 I heard that caravans take smoked fish to Uxkhal and make a good profit.\
 And next time you come here bring some wine. I will pay you well for wine.", "goods_merchant_town_info_completed",[]],
  [anyone,"goods_merchant_town_info", [[store_encountered_party,reg(1)],[eq,reg(1),"p_town_13"]],
"I have a stock of dried meat which I can sell you with a good price.\
 They say they pay very well for dried meat in Veluca, so maybe you can sell it there.\
 And next time you come here, bring some oil. I have sold out my stock of oil and I will pay you well for it.", "goods_merchant_town_info_completed",[]],
  [anyone,"goods_merchant_town_info", [[store_encountered_party,reg(1)],[eq,reg(1),"p_town_14"]],
"We produce some good quality pottery here in Halmar. Most caravans come here to buy that.\
 I heard that caravans buy pottery from here and sell it at Jelkala, making a good profit.\
 And next time you come here, bring some linen. I have sold out my stock of linen and I will pay you well for it.", "goods_merchant_town_info_completed",[]],

  [anyone,"goods_merchant_town_info", [[store_encountered_party,reg(1)],[eq,reg(1),"p_salt_mine"]],
"Heh. Are you joking with me? This is the salt mine. Merchants come here to buy salt.", "goods_merchant_town_info_completed",[]],

  [anyone,"goods_merchant_town_info", [
                                       (store_encountered_party,reg(9)),
                                       (party_get_slot,reg(5),reg(9),slot_town_export_good),
                                       (party_get_slot,reg(6),reg(9),slot_town_import_good),
                                       (ge,reg(5),1),
                                       (ge,reg(6),1),
                                       (str_store_item_name,1,reg(5)),
                                       (str_store_item_name,2,reg(6)),
                                       ],
  "I can sell you some {s1} with a special price.\
And next time you come here bring some {s2}. I will pay you well for that.", "goods_merchant_town_info_completed",[]],

  [anyone,"goods_merchant_town_info", [
                                       (store_encountered_party,reg(9)),
                                       (party_get_slot,reg(5),reg(9),slot_town_export_good),
                                       (ge,reg(5),1),
                                       (str_store_item_name,1,reg(5)),
                                       ],
  "I can sell you some {s1} with a special price.", "goods_merchant_town_info_completed",[]],

  [anyone,"goods_merchant_town_info", [
                                       (store_encountered_party,reg(9)),
                                       (party_get_slot,reg(6),reg(9),slot_town_import_good),
                                       (ge,reg(6),1),
                                       (str_store_item_name,2,reg(6)),
                                       ],
  "If you have some {s2} with you, I am ready to pay you good money for it.", "goods_merchant_town_info_completed",[]],
  
  [anyone,"goods_merchant_town_info", [],
"Sorry. Caravans hardly ever trade anything here.", "goods_merchant_town_info_completed",[]],






#############################################################################
#### ARENA MASTERS
#############################################################################

  
  [anyone ,"start", [(store_conversation_troop,reg(1)),
                     (is_between,reg(1),arena_masters_begin,arena_masters_end),
                     (troop_get_slot, reg(3), reg(1), slot_troop_met),
                     (eq, reg(3), 0),
                     (troop_set_slot, reg(1), slot_troop_met, 1),
                     ],
   "Hello. You seem to be new here. Care to share your name?", "arena_master_intro_1",[]],
  [anyone|plyr,"arena_master_intro_1", [], "I am {playername}.", "arena_master_intro_2",[]],
  [anyone,"arena_master_intro_2", [(store_encountered_party,reg(2)),(str_store_party_name,1,reg(2))],
   "Well met {playername}. I am the master of the tournaments here at {s1}. Talk to me if you want to join the games or bet on one of the teams.", "arena_master_pre_talk",[]],

  [anyone,"start", [(store_conversation_troop,reg(1)),(is_between,reg(1),arena_masters_begin,arena_masters_end),(eq,"$waiting_for_arena_fight_result",1),(eq,"$arena_join_or_watch",0),(eq,"$arena_fight_won",1)],
 "Congratulations champion. You made some pretty good moves out there. Here is your share of share of the prize money, 2 denars.", "arena_master_pre_talk",
   [(assign,"$waiting_for_arena_fight_result",0),(add_xp_to_troop,20,"trp_player"),(troop_add_gold, "trp_player",2)]],
  [anyone,"start", [(store_conversation_troop,reg(1)),(is_between,reg(1),arena_masters_begin,arena_masters_end),(eq,"$waiting_for_arena_fight_result",1),(eq,"$arena_join_or_watch",0)],
 "That's quite the bruise you're sporting. But don't worry; everybody gets trounced once in awhile. The important thing is to pick yourself up, dust yourself off and keep fighting. That's what champions do.", "arena_master_pre_talk",[[assign,"$waiting_for_arena_fight_result"]]],
  [anyone,"start", [(store_conversation_troop,reg(1)),(is_between,reg(1),arena_masters_begin,arena_masters_end),(eq,"$waiting_for_arena_fight_result",1)],
 "That was exciting wasn't it? Nothing like a good fight to get the blood flowing.", "arena_master_pre_talk",[(assign,"$waiting_for_arena_fight_result",0)]],

  [anyone ,"start", [(store_conversation_troop,reg(1)),(is_between,reg(1),arena_masters_begin,arena_masters_end)],
   "Hello {playername}. Good to see you again.", "arena_master_pre_talk",[]],
  
  [anyone,"arena_master_pre_talk",
   [(eq,"$arena_join_or_watch",1),
    (ge,"$arena_bet_amount",1),
    (eq,"$arena_bet_team","$arena_winner_team"),
    (assign,reg(5),"$arena_win_amount")],
 "You've won the bet, eh? Let me see. The sum you have earned amounts to {reg5} denars. Here you go.", "arena_master_pre_talk",
   [(troop_add_gold, "trp_player","$arena_win_amount"),(assign,"$arena_bet_amount",0),(assign,"$arena_win_amount",0)]],
  
  [anyone,"arena_master_pre_talk",
   [(eq,"$arena_join_or_watch",0),
    (ge,"$arena_bet_amount",1),
    (eq,"$arena_fight_won",1),
    (assign,reg(5),"$arena_win_amount"),
   ],
 "And you had the good sense to bet on yourself too. Hmm let me see. You have won yourself some {reg5} denars. Here you are.", "arena_master_pre_talk",
   [(troop_add_gold, "trp_player","$arena_win_amount"),(assign,"$arena_bet_amount",0),(assign,"$arena_win_amount",0)]],

  [anyone,"arena_master_pre_talk", [], "What would you like to do?", "arena_master_talk",[]],


  [anyone|plyr,"arena_master_talk", [], "About the arena fights...", "arena_master_melee",[]],
  [anyone|plyr,"arena_master_talk", [], "I need to leave now. Good bye.", "close_window",[]],

  [anyone,"arena_master_melee", [], "The next arena fight will start in a while. Hurry up if you want to take part in it.", "arena_master_melee_talk",[
    (party_get_slot, ":arena_cur_tier","$current_town",slot_town_arena_melee_cur_tier),
    (try_begin), #reg3 = num teams, reg4 = team size
      (eq, ":arena_cur_tier", 0),
      (party_get_slot, "$_num_teams","$current_town",slot_town_arena_melee_1_num_teams),
      (party_get_slot, "$_team_size","$current_town",slot_town_arena_melee_1_team_size),
    (else_try),
      (eq, ":arena_cur_tier", 1),
      (party_get_slot, "$_num_teams","$current_town",slot_town_arena_melee_2_num_teams),
      (party_get_slot, "$_team_size","$current_town",slot_town_arena_melee_2_team_size),
    (else_try),
      (party_get_slot, "$_num_teams","$current_town",slot_town_arena_melee_3_num_teams),
      (party_get_slot, "$_team_size","$current_town",slot_town_arena_melee_3_team_size),
    (try_end),
   ]],
  [anyone|plyr,"arena_master_melee_talk", [], "I want to join the next fight", "arena_master_next_melee_join",[(assign,"$arena_join_or_watch",0)]],
  [anyone|plyr,"arena_master_melee_talk", [], "I would like to watch the next fight", "arena_master_next_melee_watch",
   [(assign,"$arena_join_or_watch",1)]],
  [anyone|plyr,"arena_master_melee_talk", [], "No. perhaps later.", "arena_master_we_will_fight_not",[]],
  [anyone,"arena_master_we_will_fight_not", [], "Allright. Talk to me when you are ready.", "close_window",[]],
  [anyone,"arena_master_next_melee_join", [], "Do you want to place a bet on yourself?", "arena_master_will_you_bet",
   [(assign,"$arena_bet_amount"),(assign,"$arena_bet_team",0)]],

  [anyone|plyr,"arena_master_will_you_bet", [], "No.", "arena_master_start_fight",[]],
  [anyone|plyr,"arena_master_will_you_bet", [(store_troop_gold,reg(0)),(ge,reg(0),5)], "I want to bet 5 denars.",
   "arena_master_bet_placed",[(assign,"$arena_bet_amount",5),(troop_remove_gold, "trp_player",5)]],
  [anyone|plyr,"arena_master_will_you_bet", [(store_troop_gold,reg(0)),(ge,reg(0),15)], "I want to bet 15 denars.",
   "arena_master_bet_placed",[(assign,"$arena_bet_amount",15),(troop_remove_gold, "trp_player",15)]],
  [anyone|plyr,"arena_master_will_you_bet", [(store_troop_gold,reg(0)),(ge,reg(0),30)], "I want to bet 30 denars.",
   "arena_master_bet_placed",[(assign,"$arena_bet_amount",30),(troop_remove_gold, "trp_player",30)]],
  [anyone,"arena_master_next_melee_watch", [], "Do you want to place a bet?", "arena_master_will_you_bet",[]],
  [anyone,"arena_master_bet_placed", [(eq,"$arena_join_or_watch",1)], "Hmm. That's good. And which team do you want to place your bet on.", "arena_master_select_team",[]],
  [anyone|plyr,"arena_master_select_team", [], "The red team. I have a feeling they will win this one.",
   "arena_master_start_fight",[(assign,"$arena_bet_team",0)]],
  [anyone|plyr,"arena_master_select_team", [], "The blue team. They will sweep the ground with the reds.",
   "arena_master_start_fight",[(assign,"$arena_bet_team",1)]],
  [anyone|plyr,"arena_master_select_team", [(ge,"$_num_teams",3)], "The green team. My money is on them this time.",
   "arena_master_start_fight",[(assign,"$arena_bet_team",2)]],
  [anyone|plyr,"arena_master_select_team", [(ge,"$_num_teams",4)], "The yellow team. They will be victorious.",
   "arena_master_start_fight",[(assign,"$arena_bet_team",3)]],
  [anyone,"arena_master_bet_placed", [], "That's good. Let me record that.", "arena_master_start_fight",[]],
  
  [anyone,"arena_master_start_fight", [], "Very well. The fight starts in a moment. Good luck.", "close_window",
   [
    (store_mul,"$arena_win_amount", "$arena_bet_amount", "$_num_teams"),
    (val_mul, "$arena_win_amount", 9),
    (val_div, "$arena_win_amount", 10),
    
    (store_encountered_party,"$current_town"),
    (party_get_slot, ":arena_scene","$current_town",slot_town_arena),
    (modify_visitors_at_site,":arena_scene"),(reset_visitors),


    #Assemble participants
    (assign, ":slot_no", 0),
    (troop_set_slot, "trp_temp_array_a", ":slot_no", "trp_xerina"),
    (val_add, ":slot_no", 1),
    (troop_set_slot, "trp_temp_array_a", ":slot_no", "trp_dranton"),
    (val_add, ":slot_no", 1),
    (troop_set_slot, "trp_temp_array_a", ":slot_no", "trp_kradus"),
    (val_add, ":slot_no", 1),
    (try_for_range, reg(4), 0, 10),
      (lt, ":slot_no", 48),
      (troop_set_slot, "trp_temp_array_a", ":slot_no", "trp_regular_fighter"),
      (val_add, ":slot_no", 1),
    (try_end),
    (try_for_range, reg(4), 0, 10),
      (lt, ":slot_no", 48),
      (troop_set_slot, "trp_temp_array_a", ":slot_no", "trp_veteran_fighter"),
      (val_add, ":slot_no", 1),
    (try_end),
    (try_for_range, reg(4), 0, 10),
      (lt, ":slot_no", 48),
      (troop_set_slot, "trp_temp_array_a", ":slot_no", "trp_champion_fighter"),
      (val_add, ":slot_no", 1),
    (try_end),
    (try_for_range, reg(4), 0, 5),
      (lt, ":slot_no", 48),
      (troop_set_slot, "trp_temp_array_a", ":slot_no", "trp_sword_sister"),
      (val_add, ":slot_no", 1),
    (try_end),
    (try_for_range, reg(4), 0, 10),
      (lt, ":slot_no", 48),
      (troop_set_slot, "trp_temp_array_a", ":slot_no", "trp_hired_blade"),
      (val_add, ":slot_no", 1),
    (try_end),
    (try_for_range, reg(4), 0, 10),
      (lt, ":slot_no", 48),
      (troop_set_slot, "trp_temp_array_a", ":slot_no", "trp_mercenary"),
      (val_add, ":slot_no", 1),
    (try_end),
    (assign, "$pin_troop", "trp_temp_array_a"),
    (call_script, "script_shuffle_troop_slots", 0, 48),

    
    (try_for_range, reg(12), 0, 48),
      (troop_set_slot, "trp_temp_array_b", reg(12),reg(12)), #Initialize temp_array_b such that temp_array_b[i] = i
    (try_end),


    (store_random_in_range, "$arena_player_team", 0, "$_num_teams"),
    (try_for_range, ":i_team", 0, "$_num_teams"), # repeat for num_teams; reg(55) = cur_team
      (assign, ":team_slots_start", ":i_team"),
      (val_mul, ":team_slots_start", 8),
      (assign, ":team_slots_end", ":team_slots_start"),
      (val_add, ":team_slots_end", 8),
      (assign, "$pin_troop", "trp_temp_array_b"),
      (call_script, "script_shuffle_troop_slots", ":team_slots_start", ":team_slots_end"),
      (assign, ":cur_slot", ":team_slots_start"),
      (try_for_range, reg(6), 0, "$_team_size"), # repeat for team_size; 
        (troop_get_slot, ":cur_slot_troop", "trp_temp_array_a", ":cur_slot"),
        (try_begin), #place player
          (eq,"$arena_join_or_watch",0),
          (eq, ":i_team", "$arena_player_team"),
          (eq, reg(6), 0),
          (assign, ":cur_slot_troop", "trp_player"),
        (try_end),
        (troop_get_slot, ":cur_entry_no", "trp_temp_array_b", ":cur_slot"),
        (set_visitor,":cur_entry_no",":cur_slot_troop"),
        (val_add, ":cur_slot", 1),
      (try_end),
    (try_end),

    (try_begin),
      (eq,"$arena_join_or_watch",1),
      (set_visitor,32,"trp_player"),
    (try_end),
    (assign,"$arena_fight_won",0),
    (assign,"$arena_winner_team",-1),
    (assign,"$waiting_for_arena_fight_result",1),
    (party_get_slot, reg(6),"$current_town",slot_town_arena_melee_cur_tier),
    (val_add,reg(6),1),
    (val_mod,reg(6),3),
    (party_set_slot, "$current_town",slot_town_arena_melee_cur_tier, reg(6)),
#    (set_jump_mission,"mt_arena_melee_fight"),
    (party_get_slot, ":arena_mission_template","$current_town",slot_town_arena_template),
    (set_jump_mission,":arena_mission_template"),
    (party_get_slot, reg(7),"$current_town", slot_town_arena),
    (jump_to_scene,reg(7)),
    ]],




######################################################################################
  [trp_galeas,"start", [], "Hello {boy/girl}. If you have any prisoners, I will be happy to buy them from you.", "galeas_talk",[]],

  [trp_galeas|plyr,"galeas_talk",
   [[store_num_regular_prisoners,reg(0)],[ge,reg(0),1]],
   "Then you'd better bring your purse. I have got prisoners to sell.", "galeas_sell_prisoners",[]],
  [trp_galeas|plyr,"galeas_talk",[], "Not this time. Good-bye.", "close_window",[]],
  [trp_galeas,"galeas_sell_prisoners", [],
  "Let me see what you have...", "galeas_sell_prisoners_2",
   [[change_screen_trade_prisoners]]],
  [trp_galeas, "galeas_sell_prisoners_2", [], "You take more prisoners, bring them to me. I will pay well.", "close_window",[]],

  [party_tpl|pt_refugees,"start", [], "We have been driven out of our homes because of this war.", "close_window",[(assign, "$g_leave_encounter",1)]],
  [party_tpl|pt_farmers,"start", [], "We are just simple farmers.", "close_window",[(assign, "$g_leave_encounter",1)]],


# Random Quest related conversations
  [trp_nobleman, "start", [],
   "Who are you? What do you want? Be warned, we are fully armed and more than capable to defend ourselves. Go to your way now or you will regret it.", "nobleman_talk_1",
   [(play_sound,"snd_encounter_nobleman")]],
  [trp_nobleman|plyr, "nobleman_talk_1", [],
   "I demand that you surrender to me.", "nobleman_talk_2",[]],
  [trp_nobleman|plyr, "nobleman_talk_1", [],
   "I am sorry sir. You may go.", "close_window",[(assign, "$g_leave_encounter",1)]],
  [trp_nobleman, "nobleman_talk_2", [],
   "Surrender to a puny peasant like you? Hah. Not likely.", "close_window",[[encounter_attack]]],

  [trp_nobleman,"enemy_defeated", [], "Parley! I am of noble birth, and I ask for my right to surrender.", "nobleman_defeated_1",[]],
  [trp_nobleman|plyr,"nobleman_defeated_1", [], "And I will grant you that. If you can be ransomed of course...", "nobleman_defeated_2",[]],
  [trp_nobleman,"nobleman_defeated_2", [], "Oh, you need not worry about that. My family would pay a large ransom for me.", "nobleman_defeated_3",[]],
  [trp_nobleman|plyr,"nobleman_defeated_3", [[str_store_troop_name,1,"$nobleman_quest_giver"]], "Hmm. {s1} will be happy about this... Then you are my prisoner.", "close_window",
   [[assign,"$nobleman_quest_succeeded",1],[assign,"$nobleman_quest_nobleman_active",0]]],

# Prisoner Trains
  [party_tpl|pt_swadian_prisoner_train,"start", [[eq,"$player_relation_to_swadians",rel_ally]],
   "What do you want?", "prisoner_train_talk",[]],
  [party_tpl|pt_vaegir_prisoner_train,"start", [[eq,"$player_relation_to_vaegirs",rel_ally]],
   "What do you want?", "prisoner_train_talk",[]],

  [party_tpl|pt_swadian_prisoner_train,"start", [[eq,"$player_relation_to_swadians",rel_neutral]],
   "What do you want?", "prisoner_train_talk",[]],
  [party_tpl|pt_vaegir_prisoner_train,"start", [[eq,"$player_relation_to_vaegirs",rel_neutral]],
   "What do you want?", "prisoner_train_talk",[]],
  [anyone|plyr,"prisoner_train_talk", [],
   "Set those prisoners free now!", "prisoner_train_talk_ultimatum",[]],
  [anyone,"prisoner_train_talk_ultimatum", [],
   "Or what? You are going to attack us?", "prisoner_train_talk_ultimatum_2",[]],
  [anyone|plyr,"prisoner_train_talk_ultimatum_2", [],
   "Or I'm going to cut you into pieces and feed you to dogs.", "prisoner_train_talk_ultimatum_2a",[]],
  [party_tpl|pt_swadian_prisoner_train,"prisoner_train_talk_ultimatum_2a", [],
   "We'll see who will cut who.", "close_window",[
    [assign,"$player_relation_to_swadians",rel_enemy],
    [store_relation,reg(0),"fac_swadians","fac_player_faction"],
    [val_sub,reg(0),2],
    [set_relation,"fac_swadians","fac_player_faction",reg(0)],
    [store_relation,reg(0),"fac_swadian_caravans","fac_player_faction"],
    [val_sub,reg(0),2],
    [set_relation,"fac_swadian_caravans","fac_player_faction",reg(0)],
    [encounter_attack]
    ]],
  [party_tpl|pt_vaegir_prisoner_train,"prisoner_train_talk_ultimatum_2a", [],
   "We'll see who will cut who.", "close_window",[
    [assign,"$player_relation_to_vaegirs",rel_enemy],
    [store_relation,reg(0),"fac_vaegirs","fac_player_faction"],
    [val_sub,reg(0),2],
    [set_relation,"fac_vaegirs","fac_player_faction",reg(0)],
    [store_relation,reg(0),"fac_vaegir_caravans","fac_player_faction"],
    [val_sub,reg(0),2],
    [set_relation,"fac_vaegir_caravans","fac_player_faction",reg(0)],
    [encounter_attack]
    ]],
  [anyone|plyr,"prisoner_train_talk_ultimatum_2", [],
   "Attack you? Hell no! I just took pity on those poor souls. That's all.", "prisoner_train_talk_ultimatum_2b",[]],
  [anyone,"prisoner_train_talk_ultimatum_2b", [],
   "Find something else to take pity on. You'll live longer.", "close_window",[(assign, "$g_leave_encounter",1)]],
  [anyone|plyr,"prisoner_train_talk", [],
   "Better watch those prisoners well. They may try to run away.", "prisoner_train_smalltalk",[]],
  [anyone,"prisoner_train_smalltalk", [],
   "Don't worry. They aren't going anywhere.", "close_window",[(assign, "$g_leave_encounter",1)]],

#Caravans
  [party_tpl|pt_swadian_caravan,"start",
   [[eq,"$caravan_escort_state",1],
    [store_encountered_party,reg(1)],[eq,reg(1),"$caravan_escort_party_id"],
    [store_distance_to_party_from_party, reg(0),"$caravan_escort_destination_town","$caravan_escort_party_id"],
    [lt,reg(0),5]],
   "We have almost arrived at {s2}. We can cover the rest of the way by ourselves.\
 Here, take these {reg3} denars that I promised. I hope we travel together again someday.", "close_window",
   [
    [str_store_party_name,2,"$caravan_escort_destination_town"],
    [assign,reg(3), "$caravan_escort_agreed_reward"],
    [assign,"$caravan_escort_state",0],
    [troop_add_gold, "trp_player","$caravan_escort_agreed_reward"],
    [assign,reg(4), "$caravan_escort_agreed_reward"],
    [val_mul,reg(4), 10],
    [add_xp_as_reward,reg(4)],
    (assign, "$g_leave_encounter",1)
    ]],

  [party_tpl|pt_vaegir_caravan,"start",
   [[eq,"$caravan_escort_state",1],
    [store_encountered_party,reg(1)],[eq,reg(1),"$caravan_escort_party_id"],
    [store_distance_to_party_from_party, reg(0),"$caravan_escort_destination_town","$caravan_escort_party_id"],
    [lt,reg(0),5]],
   "We have almost arrived at {s2}. We can cover the rest of the way by ourselves.\
 Here, take these {reg3} denars that I promised. I hope we travel together again someday.", "close_window",
   [
    [str_store_party_name,2,"$caravan_escort_destination_town"],
    [assign,reg(3), "$caravan_escort_agreed_reward"],
    [assign,"$caravan_escort_state",0],
    [troop_add_gold, "trp_player","$caravan_escort_agreed_reward"],
    [assign,reg(4), "$caravan_escort_agreed_reward"],
    [val_mul,reg(4), 10],
    [add_xp_as_reward,reg(4)],
    (assign, "$g_leave_encounter",1)
    ]],
  
  [party_tpl|pt_swadian_caravan,"start",
   [[eq,"$caravan_escort_state",1],
    [store_encountered_party,reg(1)],[eq,reg(1),"$caravan_escort_party_id"]],
   "Well, we have made it so far. Do you think there will be any more danger?", "talk_caravan_escort",[]],
  [party_tpl|pt_vaegir_caravan,"start",
   [[eq,"$caravan_escort_state",1],
    [store_encountered_party,reg(1)],[eq,reg(1),"$caravan_escort_party_id"]],
   "Well, we have made it so far. Do you think there will be any more danger?", "talk_caravan_escort",[]],
  [anyone|plyr,"talk_caravan_escort", [],
   "There can be bandits nearby. Let us make haste.", "talk_caravan_escort_2a",[]],
  [anyone,"talk_caravan_escort_2a", [],
   "This is as fast as we can go.\
 We need to carry all these goods remember?", "close_window",[(assign, "$g_leave_encounter",1)]],
  [anyone|plyr,"talk_caravan_escort", [],
   "The way lies clear ahead. We can rest a little.", "talk_caravan_escort_2b",[]],
  [anyone,"talk_caravan_escort_2b", [],
   "We will get all the rest we want when we reach {s1}. Let us move on now.", "close_window",[[str_store_party_name,1,"$caravan_escort_destination_town"],(assign, "$g_leave_encounter",1)]],

  
  [party_tpl|pt_swadian_caravan,"start", [[eq,"$player_relation_to_swadians",rel_neutral]],
   "Greetings traveller.", "talk_caravan_neutral",[]],
  [party_tpl|pt_vaegir_caravan,"start", [[eq,"$player_relation_to_vaegirs",rel_neutral]],
   "Greetings traveller.", "talk_caravan_neutral",[]],
  [anyone|plyr,"talk_caravan_neutral", [], "Hand over your gold and valuables now!", "talk_train_swadian_2",[]],
  [anyone,"talk_train_swadian_2", [], "Sweet God, are you robbing us?", "talk_train_swadian_3",[]],
  [anyone|plyr,"talk_train_swadian_3", [], "Robbing you? Hell no! I was just joking.", "talk_train_swadian_3_norob",[]],
  [anyone,"talk_train_swadian_3_norob", [], "Phew. For a moment I thought we were in trouble.", "close_window",[(assign, "$g_leave_encounter",1)]],
  [anyone|plyr,"talk_train_swadian_3", [], "Damn right. I am robbing you. Now start handing over your goods.", "talk_train_swadian_4",[]],
  [party_tpl|pt_swadian_caravan,"talk_train_swadian_4", [], "Damn you. You will have to fight us first.", "close_window",
   [[assign,"$player_relation_to_swadians",rel_enemy],
    [assign,reg(3),-10],
    [store_relation,reg(0),"fac_swadians","fac_player_faction"],
    [val_min,reg(0),reg(3)],
    [set_relation,"fac_swadians",        "fac_player_faction",reg(0)],
    [set_relation,"fac_swadian_caravans","fac_player_faction",reg(0)],
    [encounter_attack]]],
  [party_tpl|pt_vaegir_caravan,"talk_train_swadian_4", [], "Damn you. You will have to fight us first.", "close_window",
   [[assign,"$player_relation_to_vaegirs",rel_enemy],
    [assign,reg(3),-10],
    [store_relation,reg(0),"fac_vaegirs","fac_player_faction"],
    [val_min,reg(0),reg(3)],
    [set_relation,"fac_vaegirs"        ,"fac_player_faction",reg(0)],
    [set_relation,"fac_vaegir_caravans","fac_player_faction",reg(0)],
    [encounter_attack]]],

  [anyone|plyr,"talk_caravan_neutral", [],
   "I can escort you to your destination for a price.", "caravan_offer_protection",[]],
  [anyone,"caravan_offer_protection", [],
   "These roads are very dangerous indeed. One can never have enough protection.", "caravan_offer_protection_2",
   [[store_encountered_party,reg(1)],
    [get_party_ai_object,reg(2),reg(1)],
    [store_distance_to_party_from_party, reg(0),reg(2),reg(1)],
    [assign,"$caravan_distance_to_target",reg(0)],
    [assign,"$caravan_escort_offer","$caravan_distance_to_target"],
    [val_div,"$caravan_escort_offer",2],
    ]],
  [anyone,"caravan_offer_protection_2", [[lt,"$caravan_distance_to_target",10]],
   "But we have almost arrived at our destination. Thanks for your offer anyway...", "close_window",[(assign, "$g_leave_encounter",1)]],
  [anyone,"caravan_offer_protection_2", [],
   "We are heading to {s1}. I will pay you {reg2} denars if you escort us until there.", "caravan_offer_protection_3",
   [[store_encountered_party,reg(1)],
    [get_party_ai_object,reg(2),reg(1)],
    [str_store_party_name,1,reg(2)],
    [assign,reg(2),"$caravan_escort_offer"]]],
  [anyone|plyr,"caravan_offer_protection_3", [],
   "Agreed.", "caravan_offer_protection_4",[]],
  [anyone,"caravan_offer_protection_4", [],
   "I want you to stay close to us along the way.\
 We'll need your help if we are ambushed by bandits.", "caravan_offer_protection_5",[]],
  [anyone|plyr,"caravan_offer_protection_5", [],
   "All right, I will stay close to you. Don't worry.", "caravan_offer_protection_6",[]],
  [anyone,"caravan_offer_protection_6", [],
   "Good. Come and collect your money when we come close to {s1}. Let's get on the way now.", "close_window",
   [[store_encountered_party,reg(1)],
    [get_party_ai_object,reg(2),reg(1)],
    [str_store_party_name,1,reg(2)],
    [assign, "$caravan_escort_destination_town", reg(2)],
    [assign, "$caravan_escort_party_id", reg(1)],
    [assign, "$caravan_escort_agreed_reward", "$caravan_escort_offer"],
    [assign, "$caravan_escort_state", 1],
    (assign, "$g_leave_encounter",1)
   ]],
  [anyone|plyr,"caravan_offer_protection_3", [],
   "Forget it...", "caravan_offer_protection_4b",[]],
  [anyone,"caravan_offer_protection_4b", [],
   "Well then, maybe another time...", "close_window",[(assign, "$g_leave_encounter",1)]],

  [anyone|plyr,"talk_caravan_neutral", [],
   "Greetings to you too. Good-bye.", "close_window",[(assign, "$g_leave_encounter",1)]],
  
  [party_tpl|pt_swadian_caravan,"start", [[eq,"$player_relation_to_swadians",rel_enemy]],
   "Be warned knave! This Caravan is under the protection of his majesty King Harlaus.\
 Step out of our way or you will face his fury!", "talk_caravan_enemy",[]],
  [party_tpl|pt_vaegir_caravan,"start", [[eq,"$player_relation_to_vaegirs",rel_enemy]],
   "Be warned knave! This Caravan is under the protection of his majesty King Yaroglek.\
 Step out of our way or you will face his fury!", "talk_caravan_enemy",[]],
  [anyone|plyr,"talk_caravan_enemy", [], "You are lucky. I do not have any business with you. You may go.", "close_window",[(assign, "$g_leave_encounter",1)]],
  [anyone|plyr,"talk_caravan_enemy", [], "Not so fast. First hand over all your goods and money.", "talk_caravan_enemy_2",[]],
  [party_tpl|pt_swadian_caravan,"talk_caravan_enemy_2", [],
   "Never. It is our duty to protect these goods. You will have to fight us, you brigand!", "close_window",
   [
    [assign,"$player_relation_to_swadians",rel_enemy],
    [store_relation,reg(0),"fac_swadians","fac_player_faction"],
    [val_sub,reg(0),4],
    [set_relation,"fac_swadians","fac_player_faction",reg(0)],
    [store_relation,reg(0),"fac_swadian_caravans","fac_player_faction"],
    [val_sub,reg(0),6],
    [set_relation,"fac_swadian_caravans","fac_player_faction",reg(0)],
    [encounter_attack],
    ]],
  [party_tpl|pt_vaegir_caravan,"talk_caravan_enemy_2", [],
   "Never. It is our duty to protect these goods. You will have to fight us, you brigand!", "close_window",
   [
    [assign,"$player_relation_to_vaegirs",rel_enemy],
    [store_relation,reg(0),"fac_vaegirs","fac_player_faction"],
    [val_sub,reg(0),4],
    [set_relation,"fac_vaegirs","fac_player_faction",reg(0)],
    [store_relation, reg(0),"fac_vaegir_caravans"],
    [val_sub,reg(0),6],
    [set_relation,"fac_vaegir_caravans","fac_player_faction",reg(0)],
    [encounter_attack],
    ]],
  [party_tpl|pt_swadian_caravan,"start", [[eq,"$player_relation_to_swadians",rel_ally]],
   "Greetings commander. It is good to have you nearby.", "talk_caravan_ally",[]],
  [party_tpl|pt_vaegir_caravan,"start", [[eq,"$player_relation_to_vaegirs",rel_ally]],
   "Greetings commander. It is good to have you nearby.", "talk_caravan_ally",[]],
  [anyone|plyr,"talk_caravan_ally", [],
   "I can escort you to your destination for a price.", "caravan_offer_protection",[]],
  [anyone|plyr,"talk_caravan_ally", [],
   "Good-bye.", "close_window",[(assign, "$g_leave_encounter",1)]],

#  [caravan_master,"enemy_defeated", [], "Ah! You have defeated us. I am ruined. Here... this is all the money I have got. Take it all.", "close_window",
#   [[troop_add_gold, "trp_player",300],[add_xp_as_reward,250]]],


#swadian parties
  [anyone|plyr,"swadian_soldiers_interrogation", [], "I am {playername}.", "swadian_soldiers_interrogation_2",[]],
  [anyone,"swadian_soldiers_interrogation_2", [], "What are you doing here?", "swadian_soldiers_interrogation_3",[]],
  [anyone|plyr,"swadian_soldiers_interrogation_3", [], "I am on my way to Zendar.", "swadian_soldiers_interrogation_4",[]],
  [anyone|plyr,"swadian_soldiers_interrogation_3", [], "I am carrying some merchandise.", "swadian_soldiers_interrogation_4",[]],
  [anyone|plyr,"swadian_soldiers_interrogation_3", [], "I am just admiring the sights.", "swadian_soldiers_interrogation_4",[]],
  [anyone,"swadian_soldiers_interrogation_4", [], "Hmm. All right. You may go now. But be careful. There is a war going on. The roads are not safe for travellers.", "close_window",[(assign, "$g_leave_encounter",1)]],
  
  [party_tpl|pt_swadian_foragers,"start", [[eq,"$player_relation_to_swadians",rel_neutral]],
   "Hold it right there. Who are you?", "swadian_soldiers_interrogation",[]],
  [party_tpl|pt_swadian_foragers,"start", [[eq,"$player_relation_to_swadians",rel_enemy]],
   "You will not survive this!", "close_window",
   [(store_relation, reg(5),"fac_swadians"), (val_sub,reg(5),1), (set_relation,"fac_swadians",0,reg(5)),(encounter_attack,0)]],
  [party_tpl|pt_swadian_foragers,"start", [[eq,"$player_relation_to_swadians",rel_ally]],
   "Our lands have been invaded. But we will drive them back.", "close_window",[(assign, "$g_leave_encounter",1)]],

  [party_tpl|pt_swadian_scouts,"start", [[eq,"$player_relation_to_swadians",rel_neutral]],
   "Hold it right there. Who are you?", "swadian_soldiers_interrogation",[]],
  [party_tpl|pt_swadian_scouts,"start", [[eq,"$player_relation_to_swadians",rel_enemy]],
   "You deserve to die a thousand deaths!", "close_window",
   [(store_relation, reg(5),"fac_swadians"), (val_sub,reg(5),2), (set_relation,"fac_swadians",0,reg(5)),(encounter_attack,0)]],
  [party_tpl|pt_swadian_scouts,"start", [[eq,"$player_relation_to_swadians",rel_ally]],
   "Venture deep into the enemy territory and find myself a caravan to raid. That's the way I will get rich.", "close_window",[(assign, "$g_leave_encounter",1)]],

  [party_tpl|pt_swadian_patrol,"start", [[eq,"$player_relation_to_swadians",rel_neutral]],
   "Hold it right there. Who are you?", "swadian_soldiers_interrogation",[]],
  [party_tpl|pt_swadian_patrol,"start", [[eq,"$player_relation_to_swadians",rel_enemy]],
   "Now you will pay for your crimes against the swadian homeland!", "close_window",
   [(store_relation, reg(5),"fac_swadians"), (val_sub,reg(5),3), (set_relation,"fac_swadians",0,reg(5)),(encounter_attack,0)]],
  [party_tpl|pt_swadian_patrol,"start", [[eq,"$player_relation_to_swadians",rel_ally]],
   "Sooner or later, friend. Victory will belong to us.", "close_window",[(assign, "$g_leave_encounter",1)]],

  [party_tpl|pt_swadian_war_party,"start", [[eq,"$player_relation_to_swadians",rel_neutral]],
   "Hold it right there. Who are you?", "swadian_soldiers_interrogation",[]],
  [party_tpl|pt_swadian_war_party,"start", [[eq,"$player_relation_to_swadians",rel_enemy]],
   "You have trespassed the sacred swadian soil! You deserve to die!", "close_window",
   [(store_relation, reg(5),"fac_swadians"), (val_sub,reg(5),3), (set_relation,"fac_swadians",0,reg(5)),(encounter_attack,0)]],
  [party_tpl|pt_swadian_war_party,"start", [[eq,"$player_relation_to_swadians",rel_ally]],
   "Sooner or later, friend. Victory will belong to us.", "close_window",[(assign, "$g_leave_encounter",1)]],

#vaegir parties
  [party_tpl|pt_vaegir_foragers,"start", [[eq,"$player_relation_to_vaegirs",rel_neutral]],
   "Hold it right there. Who are you?", "swadian_soldiers_interrogation",[(play_sound,"snd_encounter_vaegirs_neutral")]],
  [party_tpl|pt_vaegir_foragers,"start", [[eq,"$player_relation_to_vaegirs",rel_enemy]],
   "You will not survive this!", "close_window",
   [(store_relation, reg(5),"fac_vaegirs"), (val_sub,reg(5),1), (set_relation,"fac_vaegirs",0,reg(5)),(encounter_attack,0)]],
  [party_tpl|pt_vaegir_foragers,"start", [[eq,"$player_relation_to_vaegirs",rel_ally]],
   "Our lands have been invaded. But we will drive them back.", "close_window",[(play_sound,"snd_encounter_vaegirs_ally"),(assign, "$g_leave_encounter",1)]],

  [party_tpl|pt_vaegir_scouts,"start", [[eq,"$player_relation_to_vaegirs",rel_neutral]],
   "Hold it right there. Who are you?", "swadian_soldiers_interrogation",[(play_sound,"snd_encounter_vaegirs_neutral")]],
  [party_tpl|pt_vaegir_scouts,"start", [[eq,"$player_relation_to_vaegirs",rel_enemy]],
   "You deserve to die a thousand deaths!", "close_window",
   [(store_relation, reg(5),"fac_vaegirs"), (val_sub,reg(5),2), (set_relation,"fac_vaegirs",0,reg(5)),(encounter_attack,0),(play_sound,"snd_encounter_vaegirs_enemy")]],
  [party_tpl|pt_vaegir_scouts,"start", [[eq,"$player_relation_to_vaegirs",rel_ally]],
   "Venture deep into the enemy territory and find myself a caravan to raid. That's the way I will get rich.", "close_window",[(play_sound,"snd_encounter_vaegirs_ally"),(assign, "$g_leave_encounter",1)]],

  [party_tpl|pt_vaegir_patrol,"start", [[eq,"$player_relation_to_vaegirs",rel_neutral]],
   "Hold it right there. Who are you?", "swadian_soldiers_interrogation",[(play_sound,"snd_encounter_vaegirs_neutral")]],
  [party_tpl|pt_vaegir_patrol,"start", [[eq,"$player_relation_to_vaegirs",rel_enemy]],
   "Now you will pay for your crimes against the vaegir homeland!", "close_window",
   [(store_relation, reg(5),"fac_vaegirs"), (val_sub,reg(5),3), (set_relation,"fac_vaegirs",0,reg(5)),(encounter_attack,0),(play_sound,"snd_encounter_vaegirs_enemy")]],
  [party_tpl|pt_vaegir_patrol,"start", [[eq,"$player_relation_to_vaegirs",rel_ally]],
   "Sooner or later, friend. Victory will belong to us.", "close_window",[(play_sound,"snd_encounter_vaegirs_ally"),(assign, "$g_leave_encounter",1)]],

  [party_tpl|pt_vaegir_war_party,"start", [[eq,"$player_relation_to_vaegirs",rel_neutral]],
   "Hold it right there. Who are you?", "swadian_soldiers_interrogation",[(play_sound,"snd_encounter_vaegirs_neutral")]],
  [party_tpl|pt_vaegir_war_party,"start", [[eq,"$player_relation_to_vaegirs",rel_enemy]],
   "You have trespassed the sacred vaegir soil! You deserve to die!", "close_window",
   [(store_relation, reg(5),"fac_vaegirs"), (val_sub,reg(5),3), (set_relation,"fac_vaegirs",0,reg(5)),(encounter_attack,0),(play_sound,"snd_encounter_vaegirs_enemy")]],
  [party_tpl|pt_vaegir_war_party,"start", [[eq,"$player_relation_to_vaegirs",rel_ally]],
   "Sooner or later, friend. Victory will belong to us.", "close_window",[(play_sound,"snd_encounter_vaegirs_ally"),(assign, "$g_leave_encounter",1)]],

#Deserters
  [party_tpl|pt_vaegir_deserters,"start", [[ge,"$vaegir_deserters_paid",1]], "What do you want?\
 You want to pay us some more money?", "deserter_paid_talk",[]],
  [party_tpl|pt_swadian_deserters,"start", [[ge,"$swadian_deserters_paid",1]], "What do you want?\
 You want to pay us some more money?", "deserter_paid_talk",[]],
  [anyone|plyr,"deserter_paid_talk", [], "Sorry to trouble you. I'll be on my way now.", "deserter_paid_talk_2a",[]],
  [anyone,"deserter_paid_talk_2a", [], "Yeah. Stop fooling around and go make some money.\
 I want to see that purse full next time I see you.", "close_window",[(assign, "$g_leave_encounter",1)]],
  [anyone|plyr,"deserter_paid_talk", [], "No. It's your turn to pay me this time.", "deserter_paid_talk_2b",[]],
  [party_tpl|pt_vaegir_deserters,"deserter_paid_talk_2b", [], "What nonsense are you talking about? You want trouble? You got it.", "close_window",[
    (assign,"$vaegir_deserters_paid",0),
    (assign,reg(5),"$vaegir_deserter_relation_original"),
    (val_sub,reg(5),3),
    (set_relation,"fac_vaegir_deserters",0,reg(5)),
    (encounter_attack,0),
    ]],
  [party_tpl|pt_swadian_deserters,"deserter_paid_talk_2b", [], "What nonsense are you talking about? You want trouble? You got it.", "close_window",[
    (assign,"$swadian_deserters_paid",0),
    (assign,reg(5),"$swadian_deserter_relation_original"),
    (val_sub,reg(5),3),
    (set_relation,"fac_swadian_deserters",0,reg(5)),
    (encounter_attack,0),
    ]],

  
  [party_tpl|pt_vaegir_deserters,"start", [], "We are the free brothers.\
 We will fight only for ourselves from now on.\
 Now give us your gold or taste our steel.", "deserter_talk",[]],
  [party_tpl|pt_swadian_deserters,"start", [], "We are the free brothers.\
 We will fight only for ourselves from now on.\
 Now give us your gold or taste our steel.", "deserter_talk",[]],
  [anyone|plyr,"deserter_talk", [], "When I'm done with you, you'll regret ever leaving the army.", "close_window",[[encounter_attack]]],
  [anyone|plyr,"deserter_talk", [], "There's no need to fight. I am ready to pay for free passage.", "deserter_barter",[]],
  [anyone,"deserter_barter", [], "Good. You are clever. You pay us {reg5} denars. Then you can go.", "deserter_barter_2",[[assign,"$deserter_tribute",150],[assign,reg(5),"$deserter_tribute"]]],
  [anyone|plyr,"deserter_barter_2", [[store_troop_gold,reg(2)],[ge,reg(2),"$deserter_tribute"],[assign,reg(5),"$deserter_tribute"]],
   "All right here's your {reg5} denars.", "deserter_barter_3a",[[troop_remove_gold, "trp_player","$deserter_tribute"]]],
  [anyone|plyr,"deserter_barter_2", [],
   "I don't have that much money with me", "deserter_barter_3b",[]],
  [anyone,"deserter_barter_3b", [],
   "Too bad. Then we'll have to sell you to the slavers.", "close_window",[[encounter_attack]]],


  [party_tpl|pt_vaegir_deserters,"deserter_barter_3a", [], "Heh. That wasn't difficult now was it. All right. Go now.", "close_window",[
    [store_relation, reg(5),"fac_vaegir_deserters"],
    [assign,"$vaegir_deserter_relation_original",reg(5)],
    [set_relation,"fac_vaegir_deserters","fac_player_faction",-1],
    [assign,"$vaegir_deserters_paid",2],
    (assign, "$g_leave_encounter",1)
    ]],
  [party_tpl|pt_swadian_deserters,"deserter_barter_3a", [], "Heh. That wasn't difficult now was it. All right. Go now.", "close_window",[
    [store_relation, reg(5),"fac_swadian_deserters"],
    [assign,"$swadian_deserter_relation_original",reg(5)],
    [set_relation,"fac_swadian_deserters","fac_player_faction",-1],
    [assign,"$swadian_deserters_paid",2],
    (assign, "$g_leave_encounter",1)
    ]],
  

# Bandits
  [party_tpl|pt_mountain_bandits,"start", [[ge,"$mountain_bandits_paid",1]], "What do you want?\
 You want to pay us some more money?", "bandit_paid_talk",[]],
  [party_tpl|pt_forest_bandits,"start", [[ge,"$forest_bandits_paid",1]], "What do you want?\
 You want to pay us some more money?", "bandit_paid_talk",[]],
  [anyone|plyr,"bandit_paid_talk", [], "Sorry to trouble you. I'll be on my way now.", "bandit_paid_talk_2a",[]],
  [anyone,"bandit_paid_talk_2a", [], "Yeah. Stop fooling around and go make some money.\
 I want to see that purse full next time I see you.", "close_window",[(assign, "$g_leave_encounter",1)]],
  [anyone|plyr,"bandit_paid_talk", [], "No. It's your turn to pay me this time.", "bandit_paid_talk_2b",[]],
  [party_tpl|pt_mountain_bandits,"bandit_paid_talk_2b", [], "What nonsense are you talking about? You want trouble? You got it.", "close_window",[
    (assign,"$mountain_bandits_paid",0),
    (assign,reg(5),"$mountain_bandits_relation_original"),
    (val_sub,reg(5),3),
    (set_relation,"fac_mountain_bandits","fac_player_faction",reg(5)),
    (encounter_attack,0),
    ]],
  [party_tpl|pt_forest_bandits,"bandit_paid_talk_2b", [], "What nonsense are you talking about? You want trouble? You got it.", "close_window",[
    (assign,"$forest_bandits_paid",0),
    (assign,reg(5),"$forest_bandits_relation_original"),
    (val_sub,reg(5),3),
    (set_relation,"fac_forest_bandits","fac_player_faction",reg(5)),
    (encounter_attack,0),
    ]],

  
  [party_tpl|pt_mountain_bandits,"start", [], "You have so much gold and we have nothing.\
 Not fair. You give us your gold now!", "bandit_talk",[(play_sound,"snd_encounter_bandits")]],
  [party_tpl|pt_forest_bandits,"start", [], "Loitering around in this wild place may be dangerous for you {sir/madam}.\
 Why don't you give us your gold? Then you will have nothing to worry about.", "bandit_talk",[(play_sound,"snd_encounter_bandits")]],
  [anyone|plyr,"bandit_talk", [], "I am going to give you nothing but cold steel, you scum!", "close_window",[[encounter_attack]]],
  [anyone|plyr,"bandit_talk", [], "There's no need to fight. I am ready to pay for free passage.", "bandit_barter",[]],
  [anyone,"bandit_barter", [], "Good. You are clever. You pay us {reg5} denars. Then you can go.", "bandit_barter_2",[
    [assign,"$bandit_tribute",100],
    [assign,reg(5),"$bandit_tribute"]]],
  [anyone|plyr,"bandit_barter_2", [[store_troop_gold,reg(2)],[ge,reg(2),"$bandit_tribute"],[assign,reg(5),"$bandit_tribute"]],
   "All right here's your {reg5} denars.", "bandit_barter_3a",[[troop_remove_gold, "trp_player","$bandit_tribute"]]],
  [anyone|plyr,"bandit_barter_2", [],
   "I don't have that much money with me", "bandit_barter_3b",[]],
  [anyone,"bandit_barter_3b", [],
   "You are one of those fools who would die rather than pay. Works for me.", "close_window",[[encounter_attack]]],


  [party_tpl|pt_mountain_bandits,"bandit_barter_3a", [], "Heh. That wasn't difficult now was it. All right. Go now.", "close_window",[
    (store_relation, reg(5),"fac_mountain_bandits"),
    (assign,"$mountain_bandits_relation_original",reg(5)),
    (set_relation,"fac_mountain_bandits", "fac_player_faction", -1),
    (assign,"$mountain_bandits_paid",2),
    (assign, "$g_leave_encounter",1)
    ]],
  [party_tpl|pt_forest_bandits,"bandit_barter_3a", [], "Heh. That wasn't difficult now was it. All right. Go now.", "close_window",[
    (store_relation, reg(5),"fac_forest_bandits"),
    (assign,"$forest_bandits_relation_original",reg(5)),
    (set_relation,"fac_forest_bandits", "fac_player_faction", -1),
    (assign,"$forest_bandits_paid",2),
    (assign, "$g_leave_encounter",1)
    ]],
  
 
  
 
#Khergit parties
  [trp_desert_bandit,"start", [], "You thought you could outrun the desert dogs? Now give us everything you have and perhaps we will not kill you today.", "bandit_battle_reason_stated",
   []],
  [trp_desert_bandit|plyr,"bandit_battle_reason_stated", [], "I will give you nothing but cold steel you scum.", "close_window",[[encounter_attack]]],
  

  [party_tpl|pt_rescued_prisoners,"start", [], "Do you want us to follow you?", "disbanded_troop_ask",[]],
  [anyone|plyr,"disbanded_troop_ask", [], "Yes. Let us ride together.", "disbanded_troop_join",[]],
  [anyone|plyr,"disbanded_troop_ask", [], "No. Not at this time.", "close_window",[(assign, "$g_leave_encounter",1)]],
  [anyone,"disbanded_troop_join", [[neg|party_can_join]], "Unfortunately. You do not have room in your party for us.", "close_window",[(assign, "$g_leave_encounter",1)]],
  [anyone,"disbanded_troop_join", [], "We are at your command.", "close_window",[[party_join],(assign, "$g_leave_encounter",1)]],
   
  [party_tpl|pt_enemy,"start", [], "You will not capture me again. Not this time.", "enemy_talk_1",[]],
  [party_tpl|pt_enemy|plyr,"enemy_talk_1", [], "You don't have a chance against me. Give up.", "enemy_talk_2",[]],
  [party_tpl|pt_enemy,"enemy_talk_2", [], "I will give up when you are dead!", "close_window",[[encounter_attack]]],



  [anyone,"member_chat", [(store_conversation_troop,reg(3)),(troop_is_hero,reg(3))], "Yes?", "member_talk",[]],
  [anyone|plyr,"member_talk", [],
   "I have a few items that I no longer need. Would you care to barter?", "member_trade",[]],
  [anyone,"member_trade", [], "Of course. Let me see what you have got.", "do_member_trade",[[change_screen_trade]]],
  [anyone,"do_member_trade", [], "Anything else?", "member_talk",[]],
  [anyone|plyr,"member_talk", [], "Tell me about yourself", "view_member_char_requested",[]],
  [anyone,"view_member_char_requested", [], "All right then, listen to this...", "do_member_view_char",[[change_screen_view_character]]],
  [anyone|plyr,"member_talk", [], "We need to separate for a while.", "member_separate",[]],
  [anyone,"member_separate", [], "Separate? All right. What do you want me to do?", "member_separate_2",[]],
  [anyone|plyr,"member_separate_2", [], "You go and wait for me at Four Ways Inn. I'll find you there.", "member_separate_inn",[]],
  [anyone,"member_separate_inn", [], "All right then, I'll meet you at the four ways inn. Good luck.", "close_window",
   [[store_conversation_troop,reg(0)],[remove_member_from_party,reg(0)],[add_troop_to_site, reg(0), "scn_four_ways_inn", 1]]],
  [anyone|plyr,"member_separate_2", [], "Wait for me right here. I will come back for you.", "member_separate_wilderness",[]],
  [anyone,"member_separate_wilderness", [], "All right then, I'll wait for you. Hey. Don't you forget to come back for me.", "close_window",
   [[store_conversation_troop,reg(0)],[remove_member_from_party,reg(0)],[add_companion_party,reg(0)]]],
  [anyone|plyr,"member_separate_2", [], "I changed my mind. You keep following me.", "do_member_trade",[]],
  [anyone,"do_member_view_char", [], "Anything else?", "member_talk",[]],
  [anyone|plyr,"member_talk", [], "Nothing. Let us keep riding.", "close_window",[]],

  [anyone|plyr,"member_wilderness_talk", [], "Yes. Follow me.", "member_wilderness_join",[]],
  [anyone,"member_wilderness_join", [(neg|party_can_join)],
   "Darn. I am afraid you do not have enough capacity in your party for me. Why don't you try again after fixing that?", "close_window",[(assign, "$g_leave_encounter",1)]],
  [anyone,"member_wilderness_join", [], "Good. I was beginning to get bored.", "close_window",[[party_join],(assign, "$g_leave_encounter",1)]],
  [anyone|plyr,"member_wilderness_talk", [], "No. Stay here for a while longer.", "member_wilderness_no_join",[]],
  [anyone,"member_wilderness_no_join", [], "All right. All right. You go and take care of your important business.\
 Don't even think about me. What job have I got in life other than waiting for you in this God forsaken place?", "close_window",[(assign, "$g_leave_encounter",1)]],
  [anyone|plyr,"member_wilderness_talk", [], "I want to leave some troops with you.", "member_wilderness_leave_troops",[]],
  [anyone,"member_wilderness_leave_troops", [], "Really? Well, you can trust me. I will command them well.", "member_wilderness_leave_troops_2",[(change_screen_exchange_members,0)]],
  [anyone,"member_wilderness_leave_troops_2", [], "We will be waiting for you here. Be careful.", "close_window",[(assign, "$g_leave_encounter",1)]],

  [anyone|plyr,"member_inn_talk", [], "Yes. Let us ride together again.", "member_inn_join",[]],
  [anyone,"member_inn_join", [(neg|hero_can_join)],
   "Darn. I am afraid you do not have enough capacity in your party for me. Why don't you try again after fixing that?", "close_window",[(assign, "$g_leave_encounter",1)]],
  [anyone,"member_inn_join", [], "Good. I was beginning to get bored.", "close_window",[[store_conversation_troop,reg(0)],[troop_join,reg(0)],[remove_troop_from_site,reg(0)],(assign, "$g_leave_encounter",1)]],
  [anyone|plyr,"member_inn_talk", [], "No. Stay here for a while longer.", "member_inn_no_join",[]],
  [anyone,"member_inn_no_join", [], "All right. All right. You go and take care of your important business.\
 Don't even mind about me. What job have I got in life other than waiting for you in some country inn?", "close_window",[(assign, "$g_leave_encounter",1)]],



  [anyone,"member_chat", [], "Your orders {sir/madam}?", "regular_member_talk",[]],
  [anyone|plyr,"regular_member_talk", [], "Tell me about yourself", "view_regular_char_requested",[]],
  [anyone,"view_regular_char_requested", [], "Aye {sir/madam}. Let me tell you all there is to know about me.", "do_regular_member_view_char",[[change_screen_view_character]]],
  [anyone,"do_regular_member_view_char", [], "Anything else?", "regular_member_talk",[]],
  [anyone|plyr,"regular_member_talk", [], "Nothing. Keep moving.", "close_window",[]],




  [anyone,"sell_prisoner_outlaws", [[store_troop_kind_count,0,"trp_river_pirate"],[ge,reg(0),1],[assign,reg(1),reg(0)],[val_mul,reg(1),10],[val_mul,reg(2),reg(0)],[val_mul,reg(2),10]],
   "Hmmm. 10 denars for each river_pirate makes {reg1} denars for all {reg0} of them.", "sell_prisoner_outlaws",
   [[troop_add_gold, "trp_player",reg(1)],[add_xp_to_troop,reg(2)],[remove_member_from_party,"trp_river_pirate"]]],
  [anyone,"sell_prisoner_outlaws", [[store_troop_kind_count,0,"trp_bandit"],[ge,reg(0),1],[assign,reg(1),reg(0)],[val_mul,reg(1),20],[assign,reg(2),reg(0)],[val_mul,reg(2),20]],
   "Let me see. You have brought {reg0} bandits. 20 denars for each makes {reg1} denars..", "sell_prisoner_outlaws",
   [[troop_add_gold, "trp_player",reg(1)],[add_xp_to_troop,reg(2)],[remove_member_from_party,"trp_bandit"]]],
  [anyone,"sell_prisoner_outlaws", [[store_troop_kind_count,0,"trp_brigand"],[ge,reg(0),1],[assign,reg(1),reg(0)],[val_mul,reg(1),30],[assign,reg(2),reg(0)],[val_mul,reg(2),30]],
   "Well well, you have captured {reg0} brigand. Each one is worth 30 denars, that means I'll pay you a sum of {reg1}.", "sell_prisoner_outlaws",
   [[troop_add_gold, "trp_player",reg(1)],[add_xp_to_troop,reg(2)],[remove_member_from_party,"trp_brigand"]]],
  [anyone,"sell_prisoner_outlaws", [], "Well, I guess that would be all.", "sell_prisoner_outlaws_finished",[]],

  [anyone,"member_chat", [], "How about having a little chat. It will make the journey easier.", "member_chat_2",[]],
  [anyone|plyr,"member_chat_2", [], "We don't have time for that now. We should make speed.", "close_window",[]],

  [anyone|plyr,"prisoner_chat", [], "Do not try running away or trying something stupid. I will be watching you.", "prisoner_chat_2",[]],
  [anyone,"prisoner_chat_2", [], "No, I swear I won't.", "close_window",[]],


  [anyone,"start", [[store_conversation_troop,reg(3)],[ge,reg(3),weapon_merchants_begin],[le,reg(3),weapon_merchants_end]], "Hello. What can I do for you?", "merchant_talk",[]],
  [anyone,"start", [[store_conversation_troop,reg(3)],[ge,reg(3),armor_merchants_begin ],[le,reg(3),armor_merchants_end]], "Hello. What can I do for you?", "merchant_talk",[]],
  [anyone|plyr,"merchant_talk", [], "I want to buy a few things. Show me your wares.", "trade_requested",[]],
  [anyone,"trade_requested", [], "Ah, yes {sir/madam}. Please have a look at my fine selection of items.", "merchant_trade",[[change_screen_trade]]],
  [anyone,"merchant_trade", [], "Anything else?", "merchant_talk",[]],
  [anyone|plyr,"merchant_talk", [], "Tell me. What are people talking about these days?", "merchant_gossip",[]],
  [anyone,"merchant_gossip", [], "Well, nothing new lately. Prices, weather, the war, the same old things.", "merchant_talk",[]],
  [anyone|plyr,"merchant_talk", [], "Good-bye.", "close_window",[]],



  

  [anyone,"start", [(eq, "$talk_context", 0),
                    (store_encountered_party,reg(2)),
                    (store_faction_of_party,reg(5),reg(2)),
                    (eq,reg(5),"fac_player_faction"),
                    (store_conversation_troop,reg(3)),
                    (is_between,reg(3),regular_troops_begin, regular_troops_end),
                     ], "Yes {sir/madam}?", "player_castle_guard_talk",[]],
  [anyone|plyr,"player_castle_guard_talk", [], "How goes the watch, soldier?", "player_castle_guard_talk_2",[]],
  [anyone,"player_castle_guard_talk_2", [], "All quite {sir/madam}. Nothing to report.", "player_castle_guard_talk_3",[]],
  [anyone|plyr,"player_castle_guard_talk_3", [], "Good. Keep your eyes open.", "close_window",[]],

  [anyone,"start", [(eq, "$talk_context", 0),
                    (store_encountered_party,reg(2)),
                    (store_faction_of_party,reg(5),reg(2)),
                    (this_or_next|eq,reg(5),"fac_vaegirs"),
                    (eq,reg(5),"fac_swadians"),
                    (store_conversation_troop,reg(3)),
                    (is_between,reg(3),regular_troops_begin, regular_troops_end),
                     ], "Mind your manners within the city walls and we'll have no trouble", "close_window",[]],


  [anyone,"enemy_defeated", [], "Arggh! I hate this.", "close_window",[]],

  [anyone,"party_relieved", [], "Thank you for helping us against those bastards.", "close_window",[]],

  [anyone,"start", [(store_encountered_party, reg(5)),(party_get_template_id,reg(7),reg(5)),(eq,reg(7),"pt_sea_raiders")],
   "I will drink from your skull!", "battle_reason_stated",[(play_sound,"snd_encounter_sea_raiders")]],
  
  [anyone,"start", [(store_encountered_party, reg(5)),(party_get_template_id,reg(7),reg(5)),(this_or_next|eq,reg(7),"pt_steppe_bandits"),(eq,reg(7),"pt_black_khergit_raiders")],
   "Surrender or die. Make your choice", "battle_reason_stated",[(play_sound,"snd_encounter_steppe_bandits")]],



######################################
# GENERIC PARTY ENCOUNTER
######################################

  [anyone,"start", [(eq,"$talk_context",tc_party_encounter),
                    (gt,"$encountered_party_hostile",0),
                    (encountered_party_is_attacker),
                    ],
   "You have no chance against us. Surrender now or we will kill you all...", "party_encounter_hostile_attacker",
   []],
  [anyone|plyr,"party_encounter_hostile_attacker", [
                    ],
   "Don't attack! We surrender.", "close_window", [(assign,"$g_player_surrenders",1)]],
#  [anyone|plyr,"party_encounter_hostile_attacker", [
#                    ],
#   "I will pay you 1000 denars if you just let us go.", "close_window", []],
  [anyone|plyr,"party_encounter_hostile_attacker", [
                    ],
   "We will fight you to the end!", "close_window", []],
  
  [anyone,"start", [(eq,"$talk_context",tc_party_encounter),
                    (neg|encountered_party_is_attacker),
                    ],
   "What do you want?", "party_encounter_hostile_defender",
   []],

  [anyone|plyr,"party_encounter_hostile_defender", [],
   "Surrender or die!", "party_encounter_hostile_ultimatum_surrender", []],
  [anyone,"party_encounter_hostile_ultimatum_surrender", [],
   "You rascal! You will pay for this", "close_window", [(assign,"$encountered_party_hostile",1)]],

  [anyone|plyr,"party_encounter_hostile_defender", [],
   "Nothing. We'll leave you in peace.", "close_window", [(assign, "$g_leave_encounter",1)]],




  [anyone,"start", [(eq,"$talk_context",tc_join_battle_ally),
                    ],
   "You have come just in time. Let us join our forces now and teach our enemy a lesson.", "close_window",
   []],

  [anyone,"start", [(eq,"$talk_context",tc_join_battle_enemy),
                    ],
   "You are making a big mistake by fighting against us.", "close_window",
   []],

  [anyone,"start", [(eq,"$talk_context",tc_hero_freed)],
   "I am in your debt for freeing me friend.", "freed_hero_answer",
   []],

  [anyone|plyr,"freed_hero_answer", [],
   "You're not going anywhere. You'll be my prisoner now!", "freed_hero_answer_1",
   [
     (store_conversation_troop, ":cur_troop_id"), 
     (party_add_prisoners, "p_main_party", ":cur_troop_id", 1),#take prisoner
    ]],

  [anyone,"freed_hero_answer_1", [],
   "Darn. Will my luck never turn back...", "close_window",
   []],

  [anyone|plyr,"freed_hero_answer", [],
   "You are free to go wherever you want.", "freed_hero_answer_2",
   [
    ]],

  [anyone,"freed_hero_answer_2", [],
   "Thank you friend. I will not forget this. May good fortune be with you.", "close_window",
   []],

  [anyone|plyr,"freed_hero_answer", [],
   "Would you like to join me?", "freed_hero_answer_3",
   []],

  [anyone,"freed_hero_answer_3", [(store_random_in_range, ":random_no",0,2),(eq, ":random_no", 0)],
   "Allright I will join you.", "close_window",
   [
     (store_conversation_troop, ":cur_troop_id"), 
     (party_add_members, "p_main_party", ":cur_troop_id", 1),#join hero
   ]],

  [anyone,"freed_hero_answer_3", [],
   "No, I want to go on my own.", "close_window",
   [
    ]],

  [anyone,"start", [(eq,"$talk_context",tc_hero_defeated)],
   "Damn you for defeating me.", "defeat_hero_answer",
   [
    ]],

  [anyone|plyr,"defeat_hero_answer", [],
   "You are my prisoner now.", "defeat_hero_answer_1",
   [
     (store_conversation_troop, ":cur_troop_id"), 
     (party_add_prisoners, "p_main_party", ":cur_troop_id", 1),#take prisoner
    ]],

  [anyone,"defeat_hero_answer_1", [],
   "Damn you. You will regret this.", "close_window",
   []],

  [anyone|plyr,"defeat_hero_answer", [],
   "You are free to go now. But don't you step in my path again.", "defeat_hero_answer_2",
   [
     (store_conversation_troop, ":cur_troop_id"), 
    ]],

  [anyone,"defeat_hero_answer_2", [],
   "We will meet again.", "close_window",
   []],














  

  [anyone,"start", [], "Surrender or die. Make your choice", "battle_reason_stated",[]],
  [anyone|plyr,"battle_reason_stated", [], "I am not afraid of you. I will fight.", "close_window",[[encounter_attack]]],

  [anyone,"start", [], "You are going to die today", "close_window",[[encounter_attack]]],


  [anyone,"start", [], "Hello. What can I do for you?", "free",[]],
  [anyone|plyr,"free", [[neg|in_meta_mission]], "Tell me about yourself", "view_char_requested",[]],
  [anyone,"view_char_requested", [], "Ok then listen to this...", "view_char",[[change_screen_view_character]]],
  [anyone,"view_char", [], "Anything else?", "free",[]],

  [anyone|plyr,"end", [], "(Done)", "close_window",[]],
  
  [anyone|plyr,"start", [], "Drop your weapons and surrender if you want to live", "threaten_1",[]],
  [anyone,"threaten_1", [], "We will fight you first", "end",[[encounter_attack]]],

#  [anyone|plyr,"free", [[partner_is_mercmaster]], "I need to hire some mercenaries.", "mercenaries_requested",[]],
#  [anyone,"mercenaries_requested", [], "I have the toughest fighters in all Calradia.", "buy_mercenaries",[[change_screen_buy_mercenaries]]],
#  [anyone,"buy_mercenaries", [], "Anything else?", "free",[]],

#  [anyone|plyr,"free", [[partner_is_recruitable]], "I need a capable sergeant like yourself. How much do you ask to work for me?", "employ_mercenary_requested",[]],
#  [anyone,"employ_mercenary_requested", [[store_mercenary_price,0],[store_mercenary_wage,1]], "I want {reg0} denars now and {reg1} denars as monthly payment.", "employ_mercenary_2",[]],
#  [anyone|plyr,"employ_mercenary_2", [], "I see I need to think of this.", "employ_mercenary_giveup",[]],
#  [anyone|plyr,"employ_mercenary_2", [[neg|hero_can_join]], "I don't have any more room in my party right now. I will talk to you again later.", "employ_mercenary_giveup",[]],
#  [anyone|plyr,"employ_mercenary_2", [[player_gold_ge,reg(0)],[hero_can_join]], "That's fine. Here's the {reg0} denars. From now on you work for me.", "employ_mercenary_commit",[[troop_remove_gold, "trp_player",reg(0)],[recruit_mercenary]]],
#  [anyone,"employ_mercenary_giveup", [], "Suits me.", "free",[]],
#  [anyone,"employ_mercenary_commit", [], "You got yourself the best fighter in the land.", "end",[]],


  [anyone|plyr,"free", [[in_meta_mission]], " Good-bye.", "close_window",[]],
  [anyone|plyr,"free", [[neg|in_meta_mission]], " [Leave]", "close_window",[]],
#  [anyone,"free", [], "NO MATCHING SENTENCE!", "close_window",[]],
]
